SELECT
p.pid,
CONCAT(c.titlename,p.fname,' ',p.lname) AS 'ชื่อ-สกุล',
getAgeYearNum (birth,CURDATE()) AS 'อายุ',
p.hnomoi AS 'บ้านเลขที่',
p.mumoi AS 'หมู่ที่',
pu.typecode AS 'ความพิการ',
cp.incompletename AS 'ความพิการ'
FROM
person AS p
INNER JOIN ctitle AS c ON p.prename = c.titlecode
INNER JOIN coccupa AS co ON p.occupa = co.occupacode
INNER JOIN personunable1type as pu ON p.pcucodeperson=pu.pcucodeperson
INNER JOIN cpersonincomplete AS cp ON cp.incompletecode=pu.typecode
AND p.pid=pu.pid
WHERE p.pid NOT IN ((SELECT persondeath.pid FROM persondeath)) 