0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
:)ถ้าผมอยากรู้ว่าในตาราง person_chronic นั้นมีผู้ป่วย ชื่อ,นามสกุล,อายุ,บ้านเลขที่,หมู่,ตำบล,อำเภอ,จังหวัด ผมต้องใช้คำสั่ง SQL ว่าอย่างไรครับ
select c.clinic,cl.name as clinic_name,h.village_id,h.address,concat(p.pname,p.fname," ",p.lname)as ptname, p.cid ,timestampdiff(year,p.birthdate,now()) as age_y,pc.name as pttype_name,x.name as sex_name , n.name as nationality_name, e.name as education_name ,o.name as occupation_name, r.name as religion_name , y.name as marrystatus_name ,t.house_regist_type_name , f.family_no , pp.person_house_position_name ,c.*, concat(h.address," Á.",vl.village_moo," ",th.full_name) as address_name from person_chronic c left outer join person p on c.person_id =p.person_id left outer join house h on h.house_id = p.house_id left outer join village vl on h.village_id = vl.village_id left outer join thaiaddress th on th.addressid = vl.address_id left outer join pttype pc on pc.pttype = p.pttype left outer join sex x on x.code = p.sex left outer join nationality n on n.nationality = p.nationality left outer join education e on e.education = p.education left outer join occupation o on o.occupation = p.occupationleft outer join religion r on r.religion = p.religion left outer join marrystatus y on y.code = p.marrystatus left outer join person_house_position pp on pp.person_house_position_id = p.person_house_position_id left outer join family f on f.family_id = p.family_id left outer join house_regist_type t on t.house_regist_type_id = p.house_regist_type_id left outer join clinic cl on cl.clinic=c.clinic where c.clinic='002'