select concat(p.pname,p.fname,' ',p.lname) as tname,p.hn,concat(p.addrpart,' Á.',p.moopart,' µ.',t1.name,' Í.',t2.name,' ¨.',t3.name) as tt
from patient p
left outer join thaiaddress t1 on t1.codetype='3' and t1.chwpart=p.chwpart
and t1.amppart=p.amppart and t1.tmbpart=p.tmbpart
left outer join thaiaddress t2 on t2.codetype='2' and t2.chwpart=p.chwpart
and t2.amppart=p.amppart
left outer join thaiaddress t3 on t3.codetype='1' and t3.chwpart=p.chwpart
limit 1000