尝试以下查询:
select
`prodname`,
parent_cat_id,
sub_cat_id,
color,
JSON_EXTRACT(`product_items`, '$[*].quantity') AS 'qty',
JSON_EXTRACT(`product_items`, '$[*].offerprice') AS 'price'
from
product_details
where
prodid=11 AND
JSON_CONTAINS(product_items, '{"size": "S"}');
在列表中提供数组,以下是我的表结构:
CREATE TABLE `product_details` (
`prodid` int(11) AUTO_INCREMENT NOT NULL,
`prodname` varchar(255) UNIQUE NOT NULL,
`color` varchar(25) NOT NULL,
`product_items` JSON,
`attributelist` JSON,
PRIMARY KEY(prodid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
答案 0 :(得分:0)
Set Json Data in Dictionary and then Append this "Data Dictionary" in Array of type Dictionary.Like
DataDictionary["Column name"] = "Value"
DataArray.Append(DataDictionary)
Now You can get Any item.like
DataArray[indexnum]."Select item that you want by giving Key"