ตัวอย่างข้อมูล
table order
0001, aaaa, bbbb, 12345 abcd
table order_detail
1, 0001, google, plus
2, 0001, twitter, eiei
ผมทำ join แล้วได้มาเป็น
Code
SELECT order.id, order.first_name, order.last_name, order.address, order_detail.product_name, order_detail.option_name FROM order JOIN order_detail ON (order.id=order_detail.order_id)
"SELECT record.*, register.Emp_Name, department.Dep_Name, leave_type.Leave_Name, SUM(Rec_Day), SUM(Rec_Hour) FROM record inner join register on record.Emp_ID=register.Emp_ID inner join department on register.Dep_ID=department.Dep_ID inner join leave_type on leave_type.Leave_ID=record.Rec_Type where (( Date_start between '".$startDate."' and '".$endDate."') and (Date_end between '".$startDate."' and '".$endDate."' )) GROUP BY emp_id, Rec_Type";