Answer the question
In order to leave comments, you need to log in
How to build an SQL query to display one result from past dates, and several from future ones?
Hey! There is a table, in it material ID and TIMESTAMP. You need to make a query like this: find the first nearest date from past dates, and all the rest from future ones.
Answer the question
In order to leave comments, you need to log in
SELECT `date`
FROM `foo`
WHERE `id` >= (
SELECT `id`
FROM `foo`
WHERE `date` < now()
ORDER BY `id` DESC
LIMIT 1
)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question