数据结构
[内容表]
ID Name MyClass
1 abc 12,6,21
2 def 6,23,12,45,5
3 ghi 14,31,6,45
……[分类表]
ClassID ClassName
1 111
2 222
3 333
……需要实现根据ClassID,例如ClassID:12 搜索内容表MyClass字段中含12字段ID的内容。
备注:MyClass字段是以逗号分隔符保存的多个ClassID字符串。
[内容表]
ID Name MyClass
1 abc 12,6,21
2 def 6,23,12,45,5
3 ghi 14,31,6,45
……[分类表]
ClassID ClassName
1 111
2 222
3 333
……需要实现根据ClassID,例如ClassID:12 搜索内容表MyClass字段中含12字段ID的内容。
备注:MyClass字段是以逗号分隔符保存的多个ClassID字符串。
FROM `contents`
WHERE find_in_set( 12, myclass )
FROM `contents`
WHERE find_in_set( 12, myclass )这句好像可以,试一试先