和之间的mysql常量数

时间:2014-06-27 10:09:26

标签: mysql

mysql是否支持?

SELECT sa.*, st.startTime, st.endTime, st.locationID, st.id as timingID 
FROM ccf_session_attendee sa 
LEFT JOIN ccf_session_timing st
    ON st.id=sa.timingID 
WHERE "2014-11-02 07:00:00" BETWEEN Date_add(startTime, interval 1 minute)
AND Date_sub(endTime, interval 1 minute) 

我无法弄清楚这有什么问题,我无法得到任何结果。该表的记录包含startTime 2014-11-02 06:00:00 and endTime 2014-11-02 10:00:00

1 个答案:

答案 0 :(得分:0)

引号出错。试试这个:

   SELECT sa.*, st.startTime, st.endTime, st.locationID, st.id as timingID 
     FROM ccf_session_attendee sa 
LEFT JOIN ccf_session_timing st
       ON st.id=sa.timingID 
    WHERE '2014-11-02 07:00:00' BETWEEN Date_add(startTime, interval 1 minute)
                                    AND Date_sub(endTime, interval 1 minute)