有没有办法让价值从上周开始?
我尝试过使用此查询,但它似乎没有返回任何内容。
SELECT emp.firstName, emp.lastName, r.destination, r.tripDate, de.departmentName, c.manufacturer, c.yearMake, c.model, c.color FROM employee emp INNER JOIN reservations r INNER JOIN driver d INNER JOIN departments de INNER JOIN cars c WHERE emp.employeeID = d.employeeID AND r.licenseID = d.licenseID AND r.departmentID = de.departmentID AND r.carID = c.id AND r.statusID = 3 AND YEARWEEK(r.tripDate)=YEARWEEK(NOW())
我已经添加了一个日期为5月11日的条目,但y查询甚至没有返回该条目。
答案 0 :(得分:1)
试试这个:
SELECT id FROM tbl
WHERE DATE(r.tripDate) >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY
AND DATE(r.tripDate) < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY