显示上周的所有数据?

时间:2017-05-11 05:43:37

标签: mysql phpmyadmin

有没有办法让价值从上周开始?

我尝试过使用此查询,但它似乎没有返回任何内容。

  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())

这是我想要数据的当前表,表保留: enter image description here

我已经添加了一个日期为5月11日的条目,但y查询甚至没有返回该条目。

1 个答案:

答案 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