0
I have no error in my code, my question is very simple:
how to reference in the Where of a query that the search must be done by data from the day before to the current day?
for example, if I have data stored with the date 21/11/2019, I need that on the day 20/11/2019 is displayed in the table the data referring to my services the next day
i just don’t know how to reference this in the Where field, I’ve tried a few things but the results were not expected
SELECT
employees.id_employee AS idemp,
employees.nome AS nome,
GROUP_CONCAT(customers.nome
ORDER BY period) AS nome2,
GROUP_CONCAT(customers.id_customer
ORDER BY period) AS id,
GROUP_CONCAT(customers.adress
ORDER BY period) AS address,
GROUP_CONCAT(customers.phone
ORDER BY period) AS phone,
GROUP_CONCAT(events.id_event
ORDER BY period) AS idevent,
GROUP_CONCAT(events.price
ORDER BY period) AS price,
GROUP_CONCAT(events.frequence
ORDER BY period) AS freq,
GROUP_CONCAT(events.period
ORDER BY period) AS period,
GROUP_CONCAT(events.date
ORDER BY period) AS dia
FROM
events
INNER JOIN
employees ON employees.id_employee = events.id_employee
INNER JOIN
customers ON customers.id_customer = events.id_customer
WHERE employees.id_employee=events.id_employee AND events.date > CURRENT_DATE()
GROUP BY employees.nome
ORDER BY nome ASC
there is my query, on Where I need you to search only the date of the day before, and not all dates larger than the current
I believe there is a similar question already in https://stackoverflow.com/questions/13572083/grab-where-curdate-and-the-day-before-with-mysql . In this case, WHERE Employees.id_employee=Events.id_employee AND Events.date = DATE_ADD(CURDATE(), INTERVAL 1 DAY) would solve. OBS: I did not test.
– Leonardo Furlan
Try:
WHERE employees.id_employee=events.id_employee AND events.date = DATE_SUB(CURDATE(), INTERVAL 1 DAY)
.– anonimo