I have the following query:
SELECT id
FROM auctions
WHERE end_dt > TIME_TO_SEC(TIMEDIFF(end_dt, now())) > '0'
GROUP BY auctions.id
ORDER BY end_dt ASC
LIMIT 15
This is really slow. But basically, we're trying to select the most recent 15 records that are about to "end" by checking if the amount of seconds left is greater than zero.
I think I over complicated it, and figured I could do something like this:
SELECT id
FROM auctions
WHERE end_dt > now()
GROUP BY auctions.id
ORDER BY end_dt ASC
LIMIT 15
However, this returns different results.
Does anyone have a better solution?
Thank you!