ตารางที่เกี่ยวข้อง person_women_service,person_women,ovst,ovst_seq,person,house
Codeที่ ส่งออกเดิม
select pw.*, op.icode,op.qty,di.did,ovs.seq_id, a.*,p.person_id,p.cid as person_cid, concat(p.pname,p.fname,'' '',p.lname) as ptname ,p.age_y , h.address,h.road,v.village_moo,v.village_name, t.full_name as full_address_name , m.name as marrystatus_name,w.women_birth_control_name from person_women_service pw left outer join ovst_seq ovs on ovs.vn = pw.vn left outer join opitemrece op on op.vn = pw.vn left outer join drugitems di on di.icode = op.icode left outer join person_women a on a.person_women_id = pw.person_women_id left outer join person p on p.person_id = a.person_id left outer join house h on h.house_id = p.house_id left outer join village v on v.village_id = p.village_id left outer join thaiaddress t on t.addressid = v.address_id left outer join marrystatus m on m.code = p.marrystatus left outer join women_birth_control w on w.women_birth_control_id = a.women_birth_control_id