ผมเอาไปรับใน mysql db ผมไม่เข้าใจว่าผมสั่ง right join แล้วทำไมตารางที่ 2 ถึงไม่แสดงผล
ช่วยตอบด้วยครับผมไม่เข้าใจเลย
Code (SQL)
SELECT acc_monitor_log.pin,DATE(acc_monitor_log.time) AS MonitorDate,
IF(MIN(TIME(acc_monitor_log.time)) < '13:00:00',MIN(TIME(acc_monitor_log.time)),'Wait') AS TimeIn,
MAX(TIME(acc_monitor_log.time)) AS TimeOut, userinfo.name,userinfo.lastname
FROM acc_monitor_log right join userinfo on acc_monitor_log.pin = userinfo.badgenumber
WHERE acc_monitor_log.door_id = 6 AND acc_monitor_log.verified NOT LIKE '%200%' AND
DATE(acc_monitor_log.time) BETWEEN '2013-07-01' AND '2013-07-31' AND acc_monitor_log.pin LIKE '%000000001%'
GROUP BY acc_monitor_log.pin, MonitorDate, userinfo.name, userinfo.lastname
ORDER BY acc_monitor_log.pin,MonitorDate ASC
Tag : PHP, MySQL
Date :
2013-08-15 15:31:12
By :
thitikub
View :
652
Reply :
2
No. 1
Guest
Code (SQL)
SELECT acc_monitor_log.pin,DATE(acc_monitor_log.time) AS MonitorDate,
IF(MIN(TIME(acc_monitor_log.time)) < '13:00:00',MIN(TIME(acc_monitor_log.time)),'Wait') AS TimeIn,
MAX(TIME(acc_monitor_log.time)) AS TimeOut, userinfo.name,userinfo.lastname
FROM userinfo left join acc_monitor_log on acc_monitor_log.pin = userinfo.badgenumber
WHERE acc_monitor_log.door_id = 6 AND acc_monitor_log.verified NOT LIKE '%200%' AND
DATE(acc_monitor_log.time) BETWEEN '2013-07-01' AND '2013-07-31' AND acc_monitor_log.pin LIKE '%000000001%'
GROUP BY acc_monitor_log.pin, MonitorDate, userinfo.name, userinfo.lastname
ORDER BY acc_monitor_log.pin,MonitorDate ASC