我在mysql 5.7服务器上有以下表格
produit__parure
id_parure(内部)
|
ids_produits_parure(json)
|
21
|
["34809", "34823", "34813"]
|
22
|
["35703", "35854", "35877"]
|
和
produit
:
id_产品(int)
|
... 其他专栏
|
34809
|
...
|
34810
|
...
|
我尝试通过以下查询将id\u produits\u parure上的id.prod=value连接起来:
SELECT p.id_prod, pp.* FROM produit p left JOIN produit__parure pp on
JSON_CONTAINS(pp.ids_produits_parure->'$[*]', CAST(p.id_prod as JSON))
where id_prod=34809
但它在produit__;parure文件上返回NULL:
id_prod
|
身份证
|
ID_produits_parure
|
34809
|
无效的
|
无效的
|
我做错了什么?
因此,我想要的是:
id_prod
|
身份证
|
ID_produits_parure
|
34809
|
21
|
["34809", "34823", "34813"]
|
我尝试了Dan Chase的答案,但它产生了错误的结果(我有一行的id_produits_parure不等于id_prod)
id_prod
|
身份证
|
ID_produits_parure
|
34809
|
21
|
["34809", "34823", "34813"]
|
34809
|
22
|
["35703", "35854", "35877"]
|