mysql将字段逗号分隔为list
select distinct
substring_index(substring_index(a.nurse_dept, ',', b.help_topic_id+1), ',', -1)
from his_nurse as a
join mysql.help_topic b on
b.help_topic_id < (length(a.nurse_dept) - length(replace(a.nurse_dept,',',''))+1)
SELECT * FROM his_doctor
where 1 = 1
and concat
(ifnull(pinyin_code,''),ifnull(doctor_name,''),ifnull(wubi_code,''))
like concat('%',#{keyWords},'%')
and FIND_IN_SET(#{deptId}, doctor_dept)
本文介绍如何使用MySQL的Substring_Index函数将字段中的逗号分隔值转换为列表,以及如何通过join操作结合不同表中的数据,实现高效的数据筛选和查询。同时,展示了如何利用concat和FIND_IN_SET函数进行字符串拼接和查找。
843

被折叠的 条评论
为什么被折叠?



