ClockIN,ClockOUT มีชนิดเป็น TIME ส่วน LateAfter,LeaveBefore มีชนิดเป็น SMALLINT ครับ
คราวนี้เรามาเริ่มในส่วนของ SQL command กันดีกว่า
Code
SELECT (CASE WHEN '07:42:40' BETWEEN ClockIN AND ClockIN + INTERVAL LateAfter MINUTES THEN 1 ELSE 0 END) AS x
(CASE WHEN '15:42:40' BETWEEN ClockOUT AND ClockOUT + INTERVAL LeaveBefore MINUTES THEN 1 ELSE 0 END) AS y
FROM TimeConfig
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'MINUT
ES THEN 1 ELSE 0 END) AS x
(CASE WHEN '15:42:40' BETWEEN ClockOUT AND Clock' at line 1
SELECT (CASE WHEN '08:12:40' BETWEEN ClockIN AND ADDTIME(ClockIN, LateAfter) THEN 1 ELSE 0 END) AS x,
(CASE WHEN '15:42:40' BETWEEN ClockOUT AND ADDTIME(ClockOUT, LeaveBefore) THEN 1 ELSE 0 END) AS y
FROM TimeConfig