BMS-HOSxP Community

HOSxP => Report Exchange => ข้อความที่เริ่มโดย: panus_t ที่ สิงหาคม 10, 2012, 10:05:15 AM

หัวข้อ: ปรึกษาคำสั่ง MySQL ครับ
เริ่มหัวข้อโดย: panus_t ที่ สิงหาคม 10, 2012, 10:05:15 AM
ต้องการทำรายงานชื่อผู้ป่วยแพ้ยาครับ แสดงแค่ ชื่อ-สกุล และยาที่แพ้

select pt.hn,concat(pt.pname,pt.fname," ",pt.lname) as pt_name,oa.agent
from opd_allergy oa
left outer join patient pt on pt.hn=oa.hn

จากคำสั่งด้านบน จะได้ hn ซ้ำ เนื่องจากแพ้ยาหลายตัว ถ้าต้องการให้แสดง 1 เรคคอร์ด ต้องทำไรครับ
ตัวอย่าง 000011647    ........................   CO-TRIMOXAZOLE , PENICILLIN V , TETRACYCLINE
หัวข้อ: Re: ปรึกษาคำสั่ง MySQL ครับ
เริ่มหัวข้อโดย: pop_hosxp ที่ สิงหาคม 10, 2012, 10:26:47 AM
ใช้ คำสั่งนี้ select distinct hn from opd_allergy แล้ววาง variable แทนโดยใช้คำสั่งนี้ครับ

value:=getsqlsubquerydata('select agent from opd_allergy where hn="'+dbpipeline['hn']+'" ');