SQL
武六七
这个作者很懒,什么都没留下…
展开
-
group_by 类型分组查询为空时补0
select t0.staff_id, t0.staff_name, t0.tel, IFNULL(t1.amount, 0) as amountfrom lq_org_staff t0left join (SELECT count(*) as amount, t1.follow_id from lq_student t1 GROUP BY t1.follow_id) as t1 on t1.follow_id = t0.staff_id原创 2021-08-24 15:08:57 · 1128 阅读 · 0 评论 -
mysql将字段逗号分隔为list
mysql将字段逗号分隔为listselect 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.n...原创 2019-12-16 14:49:24 · 3446 阅读 · 0 评论 -
when case then:根据某字段不同联表不同表查询&根据字段不同查询条件不同
1.根据某字段不同连表不同表2.根据字段不同查询条件不同原创 2019-08-28 14:57:54 · 2889 阅读 · 2 评论 -
sql查询将多条记录逗号相隔拼接为一条
sql查询将多条记录逗号相隔拼接为一条#查询单选题、多选题正确答案并进行拼接select group_concat(distinct option_code , '' order by id asc) as answerfrom bus_exam_question_item where bus_exam_question_item.question_id = 4 and bus_exam...原创 2019-09-25 14:50:09 · 2244 阅读 · 2 评论