Answer the question
In order to leave comments, you need to log in
How to make sql query with sorting?
you need to make a selection of posts from the table
SELECT * FROM `wp_posts` WHERE post_type = 'news' LIMIT 5
Answer the question
In order to leave comments, you need to log in
SELECT COUNT(*) as c, post_id FROM wp_posts
WHERE post_type = 'news' AND time BETWEEN '2015-01-01' AND '2015-01-31 23:59:59'
GROUP BY post_id
ORDER BY c DESC
LIMIT 5
Click on one of the column headers in PhpMyAdmin (since you are showing a screenshot from it) and you will see a query according to which the DBMS showed you the sorted data.
but in general, the construction is responsible for this:
Where name_field is the name of the column by which to sort, and DESC or ASC control the sort order (ascending, descending)
UPD:
And for a period of time, use BETWEEN, as shown by Nc_Soft
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question