我有一个 mysql 表“location”和一个表“films”
位置结构
id | name | position
膜结构
id | name | locations
其中 film.locations 是一个 varchar 字段,包含 location.id 的逗号分隔值
EG 位置数据
id | NAME | POSITION
1 | name1 | p1
2 | name2 | p2
电影资料
id | name | locations
1 | name1 | 1,3
2 | name2 | 2,5
3 | name3 | 1,2,13,23,45,66,4,222,54321,(and so on)
我想要 location.id(s) 位于 film.locations 字段内的表位置中的所有行
谢谢大家!
最佳答案
您可以使用 find_in_set
加入函数:
SELECT *
FROM locations l
JOIN film f ON FIND_IN_SET(l.id, f.locations) > 0
关于MYSQL - 选择一个表中的所有行,其中它是另一个表中的id作为字符串字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47574595/