9
« เมื่อ: มิถุนายน 20, 2013, 10:27:16 AM »
ถ้าเราต้องการเพิ่ม ตาราง person แบบว่าใช้ทุกฟิล์ดเลย ต้องเขียนคำสั่งอย่างไรครับ
select d1.*,o1.*,v1.*,s.*,pe.*,se.name as sexname,p.drugallergy,p.clinic as patient_clinic,p.nationality,p.hometel as pt_tel,
p2.pttype as pttype_pttype,p2.name as pttype_name,p2.pcode as pttype_pcode,
p2.requirecode as pttype_requirecode,p2.require_hcode as pttype_require_hcode,
concat(if(d1.patient_address is null,'',d1.patient_address),' â·Ã. ',
if((p.hometel is null or p.hometel = ''),' - ',p.hometel)) as patient_address_tel,
oo.observe_id,oo.send_date_time as observe_intime,oo.leave_date_time as observe_outtime,
oo.symptom as observe_symptom,oo.nurse_activity as observe_activity,oo.note as observe_note,
oo.ward as observe_ward,pp.name as pt_priority_name,pw.name as pt_walk_name,
concat(help3_icode,' # ',if(help3_qty is null,'',help3_qty)) as help3_drug_name,x1.vn as xray_vn,
oa.*,oa.vn as oapp_vn,ro.vn as refer_vn,ro.refer_date,ro.refer_point,ro.hospcode as refer_hospcode,
concat(if(hc1.hosptype is null,'',hc1.hosptype),if(hc1.name is null,'',hc1.name)) as refer_hospname,
iaq.vn as admit_vn,w1.name as admit_ward
from doctor_order_print d1
left outer join ovst o1 on o1.vn = d1.vn
left outer join vn_stat v1 on v1.vn = d1.vn
left outer join opdscreen s on s.vn = d1.vn
left outer join pe_image pe on pe.vn = d1.vn
left outer join opd_observe oo on oo.vn = d1.vn
left outer join oapp oa on oa.vn = d1.vn
left outer join patient p on p.hn = d1.hn
left outer join xray_head x1 on x1.vn = d1.vn
left outer join pttype p2 on p2.pttype = v1.pttype
left outer join pt_priority pp on pp.id = o1.pt_priority
left outer join pt_walk pw on pw.walk_id = s.walk_id
left outer join referout ro on ro.vn = d1.vn
left outer join hospcode hc1 on hc1.hospcode = ro.hospcode
left outer join ipt_admit_queue iaq on iaq.vn = d1.vn
left outer join ward w1 on w1.ward = iaq.request_ward
left outer join sex se on se.code=p.sex
ขอรบกวนหน่อยนะครับทุกท่าน แบบว่าอยากได้มากที่สุดเลยครับ