MySQL JSON 类型查询field为null的数据

查询json类型,sku_detail值为数组,值如下:

[{
	"count": 1,
	"skuId": 50,
	"picture": "http://img.alicdn.com/bao/uploaded/i1/2455464663/TB1.u3oSFXXXXbDXFXXXXXXXXXX_!!0-item_pic.jpg",
	"realPrice": 0.1,
	"attributes": [{
		"attributeName": "颜色",
		"attributeValue": "绿色"
	},
	{
		"attributeName": "SIZE",
		"attributeValue": "XL"
	}],
	"createTime": 1537863189997,
	"updateTime": null,
	"productName": "丽尔家鹿皮巾干发吸水毛巾 洗车用品大号加厚鸡皮麂皮布擦车巾",
	"originalPrice": 0.1,
	"representUserId": null
}]

根据skuId查询并且representUserId不为空

select * from o_order where json_contains(json_array(51),sku_detail->'$[*].skuId') and
  sku_detail->'$[*].representUserId' != CAST('null' AS JSON);

你可能感兴趣的:(MySQL,mysql,json,null)