MySQL WHERE变量

时间:2015-03-06 10:58:10

标签: php mysql where

我有这样的刺痛例如: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 ???

1 个答案:

答案 0 :(得分:1)

使用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