Forum Moderators: open

Message Too Old, No Replies

Strange Query Result

         

Mister_L

3:44 pm on Aug 1, 2009 (gmt 0)

10+ Year Member



Hi,

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?

mattur

4:02 pm on Aug 1, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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

Mister_L

4:11 pm on Aug 1, 2009 (gmt 0)

10+ Year Member



Thanks mattur,that's was I meant.