我有一个mysql表“ location”和一个表“ films”
区位结构
id |名称|位置
膜结构
id |名称|地点
其中film.locations是一个varchar字段,包含由逗号分隔的location.id值
例如
位置数据
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位于film.locations字段内
感谢大伙们!
最佳答案
您可以在联接上使用find_in_set
函数:
SELECT *
FROM locations l
JOIN film f ON FIND_IN_SET(l.id, f.locations) > 0
关于mysql - MYSQL-选择表中所有表中的所有行作为字符串字段的ID,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/47574595/