ตามนี้นะครับท่าน
select r1.*,r1.name as HN,r1.name1 as Pt_Name,r1.name2 as Pt_Age,concat(r1.name3," ",r5.name11) as FullAddress,r1.name4 as Sex,r1.date1 as BirthDay,
r2.name as Occupation,r2.name1 as MarryStatus,r2.name2 as Nationality,r2.name3 as Citizenship,r2.name4 as Religion,
r3.name as BloodGroup,r3.name1 as DrugAllergy,r3.name2 as HomeTel,r3.name3 as InformName,r3.name4 as InformAddr,
r4.name as InformRelation,r4.name1 as Father,r4.name2 as Mother,r4.name3 as SPSName,r4.name4 as CardName,
r5.name as CardCODE,r5.name1 as PtRight,r5.name2 as PtRightCode,r5.date1 as RightExpire,
pt.informtel
from tempreport r1
left outer join tempreport r2 on r2.reportname=r1.reportname and r2.id=r1.id and r2.num=2
left outer join tempreport r3 on r3.reportname=r1.reportname and r3.id=r1.id and r3.num=3
left outer join tempreport r4 on r4.reportname=r1.reportname and r4.id=r1.id and r4.num=4
left outer join tempreport r5 on r5.reportname=r1.reportname and r5.id=r1.id and r5.num=5
left outer join patient pt on pt.hn=r1.name
where
r1.reportname="RB1T02" and r1.num=1
limit 10