【发布时间】:2018-08-13 13:53:32
【问题描述】:
我有两张桌子:
tbllocations
ID | Name | Type
1 | Location1 | {"0":"23","1":"27","2":"24","3":"22"}
2 | Location2 | {"0":"22","1":"25"}
tbllocationtypes
ID | title
22 | Wines
23 | Milk
24 | Cereals
25 | Drinks
26 | Beef
27 | Chicken
在Type 字段(使用这种精确格式)中,类型的外键是专门分开的
"0":"Default Foreign Key of tbllocationtype",
"1","First additional Foreign Key of tbllocationtype",
"2","Second Additional Foreign Key of tbllocaitontype"
我需要一个包含所有位置的列表,其中包含一个包含所有类型的字段:
查询结果:
IDLocation | Name | Types
1 Location1 Milk,Chicken,Cereals,Wine
2 Location2 Wines,Drinks
你能帮帮我吗?我在 MySQL 方面太糟糕了,无法发现这一点。
非常感谢
【问题讨论】:
-
'Using MySQL JSON field to join on a table' 是一个类似的问题。另请参阅评论中指向 JSON 搜索功能的链接。