33
« เมื่อ: มีนาคม 10, 2012, 22:26:28 PM »
อ้อได้แล้วคับ ลักขณะนึ้คับ
SELECT ac.print_val ,a.acc_num,ac.accused_name,ac.jamlai_number,
ac.accused_cid,of.post,of.office_name,co.court_name,a.court_date_expire,
a.court_date_finish,CONCAT(em.pname_name,em.emp_name,' ',em.emp_sname) as empname
FROM law_accused ac
LEFT OUTER JOIN law_acc a ON ac.acc_num=a.acc_num
LEFT OUTER JOIN law_office of ON SUBSTRING(ac.accused_cid,3,4)=of.id
LEFT OUTER JOIN law_court co ON a.court_id=co.id
LEFT OUTER JOIN law_emp em ON a.area_investigate=em.emp_id
WHERE of.post is not NULL
UNION ALL
SELECT ac.print_val ,a.acc_num,ac.accused_name,ac.jamlai_number,
ac.accused_cid,ofl.mypost,ofl.land,co.court_name,a.court_date_expire,
a.court_date_finish,CONCAT(em.pname_name,em.emp_name,' ',em.emp_sname) as empname
FROM law_accused ac
LEFT OUTER JOIN law_acc a ON ac.acc_num=a.acc_num
LEFT OUTER JOIN law_office_land ofl ON SUBSTRING(ac.accused_cid,3,4)=ofl.myid
LEFT OUTER JOIN law_court co ON a.court_id=co.id
LEFT OUTER JOIN law_emp em ON a.area_investigate=em.emp_id
WHERE ofl.mypost is not NULL
ขอบคุณคับ..