MySQL 表中一个字段关联字典表多个值,查询出对应字典的名称
附带SqlServer用法链接
https://www.cnblogs.com/w-yu-chen/p/12314960.html
进入正题:
1、用到MySQL的FIND_IN_SET()函数,请自行查阅API,这里只解决问题。
2、业务表存储的数据
3、字典表
4、sql
主要是子查询
SELECT t.guid, t.identitycategories, (select GROUP_CONCAT(s1.dictname) from sys_dict_item s1 where FIND_IN_SET(s1.dictid,t.identitycategories) ) identitycategoriesname FROM hy_veterans_info t WHERE t.guid ='2019122509441445226612' and t.status = '1'
5、效果图
内容仅供参考,并非百分百解决您的问题。