记录mysql语句

查询每个验方中15,20,30克药的个数

select bindmcode,count(IF(mqty=15,true,null)),count(IF(mqty=20,true,null)),count(IF(mqty=30,true,null))from hb_constitute
where bindmcode like 'YF%'
group by bindmcode

分组是取时间最晚一条记录进行分组

select u.id from (select * from hb_record_head order by createtime desc limit 1000) rh
left join hb_mini_evaluate ev on ev.head_id = rh.id

分割主症(main_ids)的id,查询相应的病症名称
select ri.id, GROUP_CONCAT(s.symptomname) as symptomname from hb_record_info ri left join hb_symptom_main s on FIND_IN_SET(s.id, ri.main_ids) GROUP BY ri.id
链接
https://www.cnblogs.com/ziyandeyanhuo/p/11114683.html
原文地址:https://www.cnblogs.com/yulehuayuan/p/12598794.html