select p.hn,p.pname,p.fname,p.lname,p.sex,p.birthday
,timestampdiff(year,p.birthday,now()) as 'age'
,p.addrpart,p.moopart
,p.tmbpart,t1.name as tambon
,p.amppart,t2.name as ampur
,p.chwpart,t3.name as changwat
from patient p
left join thaiaddress t1 on t1.addressid=concat(p.chwpart,p.amppart,p.tmbpart)
left join thaiaddress t2 on t2.addressid=concat(p.chwpart,p.amppart,'00')
left join thaiaddress t3 on t3.addressid=concat(p.chwpart,'00','00')
where timestampdiff(year,p.birthday,now()) between 60 and 100
and p.chwpart=62
and p.amppart=10
and p.tmbpart=03