Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 如何选择其值位于json数组中的列_Mysql_Sql_Arrays_Json - Fatal编程技术网

Mysql 如何选择其值位于json数组中的列

Mysql 如何选择其值位于json数组中的列,mysql,sql,arrays,json,Mysql,Sql,Arrays,Json,总之,我想 从test.population中选择*,其中数字位于(1,2,3),, 但是在(1,2,3)的位置,我想要一个返回json数组的函数。所以我想让它像这样工作 select * from test.population where Number in ('[1,2,3]') 如何将json数组放入where it子句?您可以使用以下运算符: Number member of ('[1,2,3]') 您可以使用JSON\u SEARCH()。它从MySQL 5.7开始提供,而MyS

总之,我想
从test.population中选择*,其中数字位于(1,2,3)
,, 但是在(1,2,3)的位置,我想要一个返回json数组的函数。所以我想让它像这样工作

select * from test.population where Number in ('[1,2,3]')
如何将json数组放入where it子句?

您可以使用以下运算符:

Number member of ('[1,2,3]')

您可以使用
JSON\u SEARCH()
。它从MySQL 5.7开始提供,而MySQL 8.0附带了()的
MEMBER

select * from test.population where json_search('[1,2,3]', 'one', number) is not null

样本数据和预期结果集会更好。