连接表,其中列包含JSON格式的倍数ID

时间:2015-07-11 19:52:46

标签: mysql json

我想根据2个条件获取customers表,但customers表的customer_group值以JSON格式存储。

客户表

id,name,customer_group,address
1,Test,["1","2"],Address

customer_group表

id,group_name,code
1,Group 1,type1
2,Group 2,type2

查询:

SELECT *.customers
  FROM customers
  INNER JOIN customer_group ON customer_group.id=customers.customer_group
  WHERE customer_group.code = type1 OR customer_group.code = type2
  GROUP BY customers.id;

有没有办法首先在json中提取customer_group值,然后传递给查询?

0 个答案:

没有答案