Jump to content

Archived

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

joecooper

ORDER BY goldstars ASC

Recommended Posts

im trying to do a mysql query, where it lists the rows in order of a number from 1 to 5 thats in 'goldstars' feild.

Some of the numbers in the rows are the same, so 2 can be the same number. and for this it gives error. how can i make it list by goldstars, and like if there is 2 the same, then move one to the top and other under it.
Thanks
Joe Cooper

Share this post


Link to post
Share on other sites
well, for something where you may have more than one record returned, you'll probably get the best results to order by more than just one column. for instance, if you're pulling a column called username and one called goldstars, i'd recommend running a query like this:
[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--][span style=\'color:blue;font-weight:bold\']SELECT[/span] username, goldstars [color=green]FROM[/color] [color=orange]tableName[/color] [color=green]ORDER BY[/color] goldstars, username;
[!--sql2--][/div][!--sql3--]

now, if you're actually getting a MySQL error, if you'll post the error you're receiving, i'm sure we can help you through that as well.

Share this post


Link to post
Share on other sites

×

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.