Jump to content

mysql ORDER BY two different fields


shortysbest

Recommended Posts

This basically select posts from the database (post_id is the id of the post its selecting) and ordering this by the number of rows with this post id in it.

How can I order this by amount of posts with this id (as currently), AND by date, newest ones first but in the order of number of them in the database.

 

mysql_query("SELECT post_id, COUNT(post_id) FROM postvoting GROUP BY post_id ORDER BY COUNT(post_id) DESC ");

Link to comment
https://forums.phpfreaks.com/topic/223391-mysql-order-by-two-different-fields/
Share on other sites

oh, i forgot, I need to order it by the date of the Post_id row in a different table of the same database. I want to order it by the number of rows of the same post_id in the postvoting table, and then order it by the date field in the posts table where the id of the row is equal to post_id in postvoting.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.