I have the following record in my database where I have to get all records containing any of the records.
Table record contains: $record_ids = ["123","234","111"]
Trying to search for it like the following with Laravel:
$records = DB::table('records_table')
->where('id', $id)
->whereRaw('JSON_CONTAINS(record_id, ?)', $record_ids)
->pluck('records');
I've also tried with similar solutions like:
->whereIn('record_id', $record_ids)
I'm using Laravel 5.5 and Mysql.
Update: It works when I 'manually' add it like the following:
->whereIn('record_id', ["123","234","111"])
But when fetching the array from the database it doesn't work
record_id?record_idcolumn contains all the ids from$record_ids?