0

我需要有一个历史列表,它只会出现小于或等于今天的日期,以及小于这个时间的时间。

SELECT
    *
FROM
    schedules
LEFT JOIN
    (special_details
    LEFT JOIN
        schedule_logs
    ON 
        special_details.id = special_details_id)
ON
    schedules.id = location_id
WHERE
    location_id = 146
AND date(dates) < ('2013-02-19')
  //this will check if schedule is lessthan the date and time for today.
  //and its not working...
    AND (WHERE
        date(dates) = ('2013-02-19')
        AND 
        date(end_time) < ('12:56:20'))

如果日期和时间是 2013-02-19 / 11:00:00 它应该出现。
如果 2013-02-19 / 1:00:00 不应该出现。
但是如果 2013-02-18 / 1:00:00 它应该显示为小于今天的日期。

如果您对历史列表有更好的想法,请告诉我。或添加链接。

4

1 回答 1

0

尝试这个:

SELECT
    *
FROM
    schedules
LEFT JOIN
    (special_details
    LEFT JOIN
        schedule_logs
    ON 
        special_details.id = special_details_id)
ON
    schedules.id = location_id
WHERE
    location_id = 146
    AND (
        date(dates) < ('2013-02-19')
        OR
        (date(dates) = ('2013-02-19') AND date(end_time) < ('12:56:20')
    )
于 2013-02-19T06:19:07.423 回答