Inside users table I have a json column named "agencies" that stores data as a simple array like this:
[
"0eb2edf0-50cb-44ff-a0a6-b2a104a9dc12",
"f7c748d4-8718-441e-aa69-91b890ead5ed"
],
the above is valid json. When I try to select all users that contain 0eb2edf0-50cb-44ff-a0a6-b2a104a9dc12 I get null
Is my query correct?
$users = User::whereRaw('JSON_CONTAINS(agencies->"$[*]", "0eb2edf0-50cb-44ff-a0a6-b2a104a9dc12")')->get();
is the below correct way to do write JSON select query conbsidering how I store uuids as an array inside agencies column which is defined as json?
'JSON_CONTAINS(agencies->"$[*]", "0eb2edf0-50cb-44ff-a0a6-b2a104a9dc12"
I got the idea for above select from reading: Making a Laravel 5.4 query on a JSON field containing a JSON array
but the solution in that post is different then what I am trying to do and my modification to it does not give me back any users, but instead I allways get null back.