我有两张这样的table:
Table Items
+--------------------+
| id | item |
+----+---------------+
| 1 | Table |
+----+---------------+
| 2 | couch |
+----+---------------+
| 3 | Bed |
+----+---------------+
| 4 | Chair |
+----+---------------+
| 5 | Desk |
+----+---------------+
Table Acme
+--------------------+--------+
| id | items | Client |
+----+---------------+--------+
| 1 | 1,3,5 | S45-56 |
+----+---------------+--------+
我需要的是使用acme表中的csv来选择items表中的项目
我尝试使用以下查询,但只得到树值中的第一个
SELECT * FROM Items WHERE id IN (SELECT items FROM Acme WHERE client ='S45-56')
你知道吗?
1条答案
按热度按时间cx6n0qe31#
你可以用
find_in_set()
检查值是否在逗号分隔的列表中。但最好修复您的模式,不要使用逗号分隔的列表,而是在一个表中使用多行。