คำสั่ง sql เดิม run ได้ไม่ปัญหา
select i.sub_group_list,l.lab_items_sub_group_code,concat(p.pname,p.fname," ",p.lname) as ptname,i.icode,
d.name as request_doctor_name,
h.*,l.*,i.lab_items_unit,i.lab_items_normal_value ,i.lab_items_name,lsg.lab_items_sub_group_name,s.name,d.name,ks.department as room,i.service_price
from lab_head h
left outer join lab_order l on l.lab_order_number=h.lab_order_number and l.confirm="Y"
left outer join lab_items i on i.lab_items_code=l.lab_items_code
left outer join lab_items_sub_group lsg on lsg.lab_items_sub_group_code=l.lab_items_sub_group_code
left outer join patient p on p.hn=h.hn
left outer join doctor d on d.code=h.doctor_code
left outer join sex s on s.code = p.sex
left outer join kskdepartment ks on ks.depcode=h.order_department
where h.lab_order_number = 1011
order by l.lab_items_sub_group_code,i.display_order,i.lab_items_name
แต่ถ้า select i.sub_group_list,l.lab_items_sub_group_code,concat(p.pname,p.fname," ",p.lname) as ptname,i.icode,
d.name as request_doctor_name,
h.*,l.*,i.lab_items_unit,i.lab_items_normal_value ,i.lab_items_name,lsg.lab_items_sub_group_name,s.name,d.name,ks.department as room,i.service_price
from lab_head h
left outer join lab_order l on l.lab_order_number=h.lab_order_number and l.confirm="Y"
left outer join lab_items i on i.lab_items_code=l.lab_items_code
left outer join lab_items_sub_group lsg on lsg.lab_items_sub_group_code=l.lab_items_sub_group_code
left outer join patient p on p.hn=h.hn
left outer join doctor d on d.code=h.doctor_code
left outer join sex s on s.code = p.sex
left outer join kskdepartment ks on ks.depcode=h.order_department
where h.lab_order_number = 1011
AND lab_order.confirm="Y" and lab_order.lab_order_result is not null or lab_order.lab_order result<>""
order by l.lab_items_sub_group_code,i.display_order,i.lab_items_name
โปรแกรม run ไม่ได้นะครบั