我能以某种方式加入这两个查询吗?:
SELECT SUM(count) AS sum_count FROM prescription
WHERE dep_id='4' AND hist_id='?' AND med_id='?' AND status='active'
和
SELECT * FROM prescription p
JOIN medicament_list ml ON ml.id=p.med_id
WHERE dep_id='4' AND hist_id='?' AND med_id='?' AND status='active'
答案 0 :(得分:0)
在这里找到解决方案:
SELECT medicament_list.med_name, SUM(prescription.count) AS sum_count FROM prescription JOIN medicament_list ON medicament_list.id=prescription.med_id WHERE dep_id='4' AND hist_id='?' AND med_id='?' AND status='active'