Forum Moderators: open
I have the following query:
"SELECT * FROM products WHERE enable='Y' AND title LIKE '%ABC%' ORDER BY total_rating,total_reviews DESC";
Here are the total_rating and total_reviews columns I get as output(I didn't change the order of the results):
total reviews - total rating
0 - 0
0 - 0
2 - 4.5
12- 4.8
4 - 5
3 - 5
1 - 5
How does it make sense?
ORDER BY total_rating,total_reviews DESC
Means order by total_rating (default order: ascending) then order by total_reviews DESCending. The second order by column only comes into play when the first sort order column's values are the same.
You don't actually describe what you're trying to achieve, but presumably you want:
ORDER BY total_rating DESC, total_reviews DESC