select a.*,
(select GROUP_CONCAT(d.name) from blade_dict d where FIND_IN_SET(d.id, a.repeat)) as 'repeatName2'
from smt_auto a
order by id desc
FIND_IN_SET(str,strlist)函数:
参数str:要查询的字符串
参数strlist:字段名 参数以”,”分隔 如 (1,2,6,8)
查询字段(strlist)中包含(str)的结果,返回结果记录就是预期。
group_concat函数:
连接分组结果
最终效果如下:
灵感来自于http://www.cnblogs.com/wx491592452/p/6404514.html
更多iOS、Android、Python、Java、MySQL的文章,请点击:
http://blog.youkuaiyun.com/jamiecheung
http://blog.youkuaiyun.com/u010841622