Answer the question
In order to leave comments, you need to log in
How to select data from SQL table for the last day, by datetime field?
There is a table in which there is a created column with the datetime format: 2015-11-20 15:22:47
You need to get all rows from the table, according to the created field for the last day, the nearest one (it can be either today or a few days ago), which is in the table. SELECT * FROM table WHERE created=?
Is it possible to do with one request?
Answer the question
In order to leave comments, you need to log in
SELECT `t`.*
FROM (
SELECT DATE(MAX(`created`)) AS `date`
FROM `table`
) AS `d`
JOIN `table` AS `t` ON `t`.`created` >= `d`.`date`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question