I have a table with items that have a datetime column called add_time
I want to do this:
take 5 elements that was added before element with id 10 for example.
I see only one way to doing this, here it is but mysql return zero rows.
SELECT i.*
FROM `image` AS `i`
LEFT JOIN `image` AS `i2` ON i.id = i2.id
WHERE i2.id =1317
AND i.`add_date` < i2.`add_date`
ORDER BY i.add_date DESC
LIMIT 0 , 5
1 Answer