Reputation: 2051
I have two columns in a table say, LIKE and FAVORITES (int value)
See the chart:
╔════╦══════╦══════════╗
║ ID ║ LIKE ║ FAVORITE ║
╠════╬══════╬══════════╣
║ 1 ║ 25 ║ 9 ║
║ 2 ║ 5 ║ 17 ║
║ 3 ║ 6 ║ 1 ║
║ 4 ║ 45 ║ 0 ║
║ 5 ║ 3 ║ 44 ║
╚════╩══════╩══════════╝
Now, I want to select the Maximum Like and Favorites IDs from the SELECT clause. I have tried
SELECT ID from TABLE WHERE CONDITION ORDER BY LIKE,FAVORITES DESC
But the result shows the rows based on LIKE DESC order.
The result should be
╔════╗
║ ID ║
╠════╣
║ 5 ║
║ 4 ║
║ 1 ║
║ 2 ║
║ 3 ║
╚════╝
Upvotes: 1
Views: 934
Reputation: 263693
I think you need to add those two columns. eg,
SELECT ID
FROM tableName
ORDER BY `LIKE` + FAVORITE DESC
Result:
╔════╗
║ ID ║
╠════╣
║ 5 ║
║ 4 ║
║ 1 ║
║ 2 ║
║ 3 ║
╚════╝
Upvotes: 1