location字段是json类型
location json not null
示例数据内容:
{"city": {"code": "330100", "name": "杭州市"}, "province": {"code": "33000", "name": "浙江省"}}
要查杭州市的
select * from life_car_sources
where location->'\$.city.code'='330100';
$query->whereRaw(sprintf("location->'\$.city.code'='%6s'", $code));
对于images json数组
["https://t9.baidu.com/it/u=871642577,2885145290&fm=173&app=49&f=JPEG?w=312&h=208&s=87026CA50E1329CA04A941A103001002", "https://t9.baidu.com/it/u=1413090630,1422875006&fm=218&app=92&f=JPEG?w=121&h=75&s=152042B1685316C6381041B50300C001"]
取首个图片
DB::raw("images->'$[0]' as images")