select u.id,u.user_url,u.user_login,u.last_login_time,u.last_login_ip,u.user_status,group_concat(h.h_name) as h_names from cmf_user as u left join cmf_hospital as h on find_in_set(h.id,u.hospital_id) where user_type=1 group by u.id
user表中有个hospital_id的字段, 以(1,2,3)格式存储,通过这个SQL语句,就能将这个1,2,3,所在的hospital表中代表的值一一列出.
网友评论