งั้นลองตรวจ Query ให้ผมหน่อยด้วยเลยครับ
ทะเบียนการประเมินพัฒนาการเด็ก 0-5 ปี และพัฒนาการล่าช้า
SELECT p.pname,p.fname,p.lname,pwn.age_m,pwn.age_y,p.cid,pt.addrpart,v.village_moo,CONCAT("ต. ",t3.`name`)AS tumbon,
CONCAT("อ. ",t2.`name`)AS ampue,CONCAT("จ. ",t1.`name`)AS chungwat,pt.moopart,pt.tmbpart,pt.amppart,pt.chwpart,
pwn.nutrition_date,pwn.body_weight,pwn.height,pnc.person_nutrition_childdevelop_type_name,
nl.name AS nutri_name,hl.name AS height_name,pnc.person_nutrition_childdevelop_type_id,nl.nutrition_level,hl.height_level
FROM person_wbc pw
LEFT OUTER JOIN person p ON p.person_id = pw.person_id
LEFT OUTER JOIN person_wbc_nutrition pwn ON pwn.person_wbc_id = pw.person_wbc_id
LEFT OUTER JOIN patient pt ON pt.hn = p.patient_hn
LEFT OUTER JOIN person_nutrition_childdevelop_type pnc ON pnc.person_nutrition_childdevelop_type_id = pwn.person_nutrition_childdevelop_type_id
LEFT OUTER JOIN nutrition_level nl ON nl.nutrition_level = pwn.nutrition_level
LEFT OUTER JOIN height_level hl ON hl.height_level = pwn.height_level
LEFT OUTER JOIN person_anc pa ON pa.person_id = p.person_id
LEFT OUTER JOIN person p3 on p3.person_id = p.mother_person_id
LEFT OUTER JOIN thaiaddress t1 on t1.addressid = concat(pt.chwpart,"0000")
LEFT OUTER JOIN thaiaddress t2 on t2.addressid = concat(pt.chwpart,pt.amppart,"00")
LEFT OUTER JOIN thaiaddress t3 on t3.addressid = concat(pt.chwpart,pt.amppart,pt.tmbpart)
LEFT OUTER JOIN village v ON v.village_id = p.village_id
WHERE pwn.age_y<="5" AND pwn.nutrition_date BETWEEN "2014-02-01" AND "2014-02-28"
AND p.village_id<>"1" AND v.village_moo<>"1"