lundi 12 février 2018

mySQL - Random but prioritising records added in last six hours

I have a table called adverts, which I pull random records from

SELECT * FROM adverts ORDER BY rand()

Using the records date field, how can I prioritise only pulling random records added in the last 6 hours.

If there are no entries in the last six hours, then try 12, 18, so on

Any tidy way to do this?




Aucun commentaire:

Enregistrer un commentaire