I used to find whether the searching item is exist in the JSON datatype column or not.
I use,
TABLE::whereRaw('json_contains(list, \'["value"]\')')->get();
this to return those are having the "value" in "list" JSON column.
But, how can i use reverse method to list, those are not having this value in json column in laravel.
Thank you !
You can use not
:
TABLE::whereRaw('not json_contains(list, \'["value"]\')')->get();
In Laravel 5.6.24 you can use whereJsonDoesntContain()
:
TABLE::whereJsonDoesntContain('list', 'value')->get();
DB::table('table')->whereNull('list->key')->get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With