Sort mysql data by count and timestamp
I'm trying to have a 'trending' search terms spot on my site that returns both the searches with most counts, but only from the las开发者_运维技巧t 24 hours.
The query I'm using to return the searches with most counts is:
SELECT searchstring
FROM trending
ORDER BY count DESC
LIMIT 5
My table columns are:
- id
- searchstring
- count
- timestamp
SELECT searchstring
FROM trending
WHERE
timestamp > DATE_SUB(NOW(), INTERVAL 1 DAY)
ORDER BY count DESC
LIMIT 5
精彩评论