Php 在查询中可以有另一个WHERE
我需要有一个历史记录列表,它只显示小于或等于今天的日期,以及小于此时间的时间Php 在查询中可以有另一个WHERE,php,mysql,sql,Php,Mysql,Sql,我需要有一个历史记录列表,它只显示小于或等于今天的日期,以及小于此时间的时间 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
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'))
选择
*
从…起
时间表
左连接
(特别资料)
左连接
调度日志
在…上
特殊_details.id=特殊_details_id)
在…上
schedules.id=位置\u id
哪里
位置_id=146
日期<('2013-02-19')
//这将检查日程安排是否少于今天的日期和时间。
//而且它不起作用。。。
和(在哪里
日期=('2013-02-19')
及
日期(结束时间)<('12:56:20'))
如果日期和时间为2013-02-19/11:00:00,则应显示该日期和时间。如果2013-02-19/1:00:00不应出现。
但如果是2013-02-18/1:00:00,则应显示为比今天的日期短 如果你对历史清单有更好的了解,请告诉我。或添加链接。尝试以下操作:
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')
)
选择
*
从…起
时间表
左连接
(特别资料)
左连接
调度日志
在…上
特殊_details.id=特殊_details_id)
在…上
schedules.id=位置\u id
哪里
位置_id=146
及(
日期<('2013-02-19')
或
(日期=('2013-02-19')和日期(结束时间)<('12:56:20'))
)
不,如果不确定,您可以使用case,但不应该是和(其中只是一个或?日期==一个日期,对吗?结束时间==小时:分钟:秒?为什么不尝试dates