为什么这不能用于从上周提取数据?
if($_GET['reminder'] == 'lastweek') {
$lastweek = date('Y-m-d', strtotime('last sunday'));
$query = "SELECT * FROM contacttodo,contacts WHERE contacttodo.contacts_id = contacts.ID AND contacttodo.reminder BETWEEN '$lastweek' AND '$lastweek' - INTERVAL 6 DAY ORDER BY contacttodo.reminder ASC";
答案 0 :(得分:0)
这是BETWEEN的定义:
expr BETWEEN min AND max
所以你应该把较小的值(最小值)放在第一位:
BETWEEN '$lastweek' - INTERVAL 6 DAY AND '$lastweek'
'$lastweek' - INTERVAL 6 DAY ORDER
小于'$lastweek'