MySQL WHERE 变量
MySQL WHERE variable
我有这个刺,例如:11,22,33
这就是我 table
:
ID / content
---------------------
1 / 11,15,18,20,22,28,29,30,
2 / 10,11,17,20,22,27,33,40,
3 / 4,8,9,15,22,23,24,31,33,
4 / 10,11,20,22,30,33,40,41,
5 / 5,6,7,10,11,22,28,30,33,
6 / 10,11,12,13,14,15,20,22,
id 1只包含11和22
id 2 包含来自 strin 的所有项目:11、22 和 33
id 3只包含22和33
id 4 包含来自 strin 的所有项目:11、22 和 33
id 5 包含来自 strin 的所有项目:11、22 和 33
id 6只包含11和22
如何创建我的 MYSQL 命令来只读取 ID 为:2,4,5
的项目
SELECT *
FROM table
WHERE content ???
使用find_in_set
SELECT *
FROM table
WHERE find_in_set ('11',content) and find_in_set ('22',content) and find_in_set ('33',content)
有关详细信息,请阅读 documentation
我有这个刺,例如:11,22,33
这就是我 table
:
ID / content
---------------------
1 / 11,15,18,20,22,28,29,30,
2 / 10,11,17,20,22,27,33,40,
3 / 4,8,9,15,22,23,24,31,33,
4 / 10,11,20,22,30,33,40,41,
5 / 5,6,7,10,11,22,28,30,33,
6 / 10,11,12,13,14,15,20,22,
id 1只包含11和22
id 2 包含来自 strin 的所有项目:11、22 和 33
id 3只包含22和33
id 4 包含来自 strin 的所有项目:11、22 和 33
id 5 包含来自 strin 的所有项目:11、22 和 33
id 6只包含11和22
如何创建我的 MYSQL 命令来只读取 ID 为:2,4,5
的项目SELECT *
FROM table
WHERE content ???
使用find_in_set
SELECT *
FROM table
WHERE find_in_set ('11',content) and find_in_set ('22',content) and find_in_set ('33',content)
有关详细信息,请阅读 documentation