BMS-HOSxP Community
HOSxP => MySQL => ข้อความที่เริ่มโดย: P1005 ที่ มีนาคม 08, 2013, 18:23:10 PM
-
cid ซ้ำกันยังแสดงผลหลายแรคคอร์ดล่ะครับ ปกติมันต้องแสดงแค่ แรคคอร์ด เดียวไม่ใช่เหรอครับ
select distinct(pt.cid),pt.hn,pt.pname,pt.fname,pt.lname,pt.informaddr,opd.cc
from vn_stat ov ,patient pt ,ovst ovst,opdscreen opd
where opd.vn=ov.vn and ov.vn=ovst.vn and pt.hn=ov.hn and ov.vstdate between "2012-10-01" and "2012-10-10" and ov.hn=pt.hn
and ov.age_y>= 0
and ov.age_y<= 200
and ( (ov.pdx >= "E110" and ov.pdx <= "E119")
or (ov.dx0 >= "E110" and ov.dx0 <= "E119")
or (ov.dx1 >= "E110" and ov.dx1 <= "E119")
or (ov.dx2 >= "E110" and ov.dx2 <= "E119")
or (ov.dx3 >= "E110" and ov.dx3 <= "E119")
or (ov.dx4 >= "E110" and ov.dx4 <= "E119")
or (ov.dx5 >= "E110" and ov.dx5 <= "E119") )
-
ลองแบบนี้ครับ
select pt.cid,pt.hn,pt.pname,pt.fname,pt.lname,pt.informaddr,opd.cc
from vn_stat ov ,patient pt ,opdscreen opd
where opd.vn=ov.vn and pt.hn=ov.hn and
ov.vstdate between "2012-10-01" and "2012-10-10" and
ov.age_y>= 0 and ov.age_y<= 200 and
( (ov.pdx >= "E110" and ov.pdx <= "E119")
or (ov.dx0 >= "E110" and ov.dx0 <= "E119")
or (ov.dx1 >= "E110" and ov.dx1 <= "E119")
or (ov.dx2 >= "E110" and ov.dx2 <= "E119")
or (ov.dx3 >= "E110" and ov.dx3 <= "E119")
or (ov.dx4 >= "E110" and ov.dx4 <= "E119")
or (ov.dx5 >= "E110" and ov.dx5 <= "E119") )
group by pt.cid
-
หรือว่าใน patient มี cid ซ้ำอยู่ครับ
-
หรือว่าใน patient มี cid ซ้ำอยู่ครับ
ก็ใช้วิธีการตรวจสอบทีละตารางกับ cid ที่ออกมาซ้ำเป็นข้อมูลตัวอย่างครับ แล้วเราจะรู้ว่าเป็นเพราะอะไร กับ Query เราครับ