Home > Mobile >  Search in json column not working in laravel
Search in json column not working in laravel

Time:10-26

I have one table which contains json string column ,i want to search inside the json column for that i am using whereJsonContains method but still it’s showing empty records but the data is there .did i miss anything .

$id=98; $reqid=7; Table::whereJsonContains(“json_data->”.$id ,$reqid)->get();

My json data is {“94”:”3”,”98”:”7”}

I was trying to fetch that column data and make it an array but it’s taking more time to execute so i want to do in query level for that i tried with whereJsonContains

CodePudding user response:

I am not sure about whereJsonContains but following way will work

$result = Table::where(“json_data->$id” ,$reqid)->get();
dd($result);
  • Related