我正在使用此查询。
在数据库结构column_name中转换成Json格式,如下所示:
[ { "Date": "2022-11-14T10:45:05.424+01:00", "Name": "nilesh1", "Level": "1" }, { "Date": "2022-11-14T10:54:15.776+01:00", "Name": "nilesh2", "Level": "2" } ]
我必须在 Laravel eloquent 中使用以下查询:
select [customername] as [customerName] from [opf_details] CROSS APPLY OPENJSON (column_name,'$') where JSON_VALUE(value,'$.Name') LIKE '%nilesh1%'
P粉5641921312024-03-30 00:47:52
我这样做了:
myModel::whereRaw('JSON_CONTAINS(`column_name`, '\{"Name":"nilesh2"}\')')