- 问题描述:通知记录表包含通知人字段,以逗号分隔多个用户的id,现需要输入用户的中文名模糊搜索对应的通知记录。
- 主要内容:
- concat(String...str) : 将多个字符串拼接起来;
- group_concat(columnName) : 将分组中的字段拼接起来;
- find_in_set(str,strlist) : 该函数的作用是查询字段strlist(逗号分隔)中是否包含(str)的结果;
- 解决方法:
select * from t_notification_record as tnr where (select upper(group_concat(name)) from t_user_info as tui where FIND_IN_SET(tui.id,nr.receivers)) like concat('%',upper(#{keyword}),'%');