คือผมอยากจะรวมตาราง และ group by user ให้ได้ตามแบบข้างล่าง ผมใช้ Union ติดตรง ผม group by user ไม่ได้
Code (PHP)
$query_Recordset1 = "SELECT Customer,Date,User FROM table1 where Customer = '$customer' and Year(Date) = '$year'
UNION
SELECT Customer,Date,User FROM table2 where Customer = '$customer' and Year(Dateplan) = '$year' ";
select * from (
SELECT Customer,Date,User FROM table1 where Customer = '$customer' and Year(Date) = '$year'
UNION
SELECT Customer,Date,User FROM table2 where Customer = '$customer' and Year(Dateplan) = '$year'
) as tmp group by [fieldที่ต้องการ]