ลองเอาไปรันดูนะ
select pt.hn,concat(pt.pname,pt.fname," ",pt.lname),vs.age_y,em.name as er_type,er.vstdate,er.er_list,p.name as period ,
icd.name as dx,icd.tname as dxtname ,opd.cc,opd.pe
from er_regist er
left outer join vn_stat vs on vs.vn = er.vn
left outer join opdscreen opd on opd.vn = er.vn
left outer join patient pt on pt.hn = vs.hn
left outer join er_period p on p.er_period = er.er_period
left outer join er_emergency_type em on em.er_emergency_type = er.er_emergency_type
left outer join er_dch_type dch on dch.er_dch_type = er.er_dch_type
left outer join icd101 icd on icd.code = vs.pdx
where er.er_dch_type = "4" and er.vstdate between "2007-01-01" and "2010-05-11"