使用WHERE IN子句检查多维数组中的值的SQL查询

时间:2022-05-19 11:49:39

MY tables has entries in following format

我的表格有以下格式的条目

ID DATA
1  {"rows":[{"unit":"10","price":"20"},{"unit":"20","price":"30"},{"unit":"30","price":"40"},{"unit":"40","price":"50"}],"table":"\n<table>\n<thead>\n<tr>\n<th>Unit</th>\n<th>Price</th>\n</tr>\n</thead>\n\n<tbody>\n\n<tr><td>10</td><td>20</td></tr><tr><td>20</td><td>30</td></tr><tr><td>30</td><td>40</td></tr><tr><td>40</td><td>50</td></tr>\n\n</tbody>\n\n</table>\n"}

I want entries where unit = 30.

我想要单位= 30的条目。

I tried

 SELECT * from content Where '30' IN "(".implode(',',`data`).");

but that returns an error. Please Help

但是会返回错误。请帮忙

1 个解决方案

#1


0  

How about:

SELECT * FROM content WHERE data LIKE '%"unit":"30"%';

#1


0  

How about:

SELECT * FROM content WHERE data LIKE '%"unit":"30"%';