ช่วยดู code ให้หน่อยครับ อยากได้ที่อยู่คนไข้ด้วยครับ ขอบคุณครับ
select concat(pname,fname,' ',lname) as ptname,a.age_y,a.hn,a.an,a.regdate,a.dchdate,
a.admdate,a.pdx,c.name as pdxname
from an_stat a
left outer join patient b on a.hn=b.hn
left outer join icd101 c on c.code=a.pdx
where c.code in ('J459','J46','J441','J440','J449')
and dchdate between'2006-01-01'and'2006-02-17'
select concat(pname,fname,' ',lname) as ptname,a.age_y,a.hn,a.an,a.regdate,a.dchdate,
a.admdate,a.pdx,c.name as pdxname,
if((b.moopart is null) or (b.moopart=""),CONCAT(b.addrpart," หมู่ - ",t.full_name),CONCAT(b.addrpart," หมู่ ",b.moopart," ",t.full_name))as address
from an_stat a
left outer join patient b on a.hn=b.hn
left outer join icd101 c on c.code=a.pdx
left outer join thaiaddress t on concat(b.chwpart,b.amppart,b.tmbpart)=t.addressid
where c.code in ('J459','J46','J441','J440','J449')
and dchdate between'2012-01-01'and'2012-02-17'