Jump to content

ORDER BY goldstars ASC


joecooper

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
Link to comment
https://forums.phpfreaks.com/topic/4977-order-by-goldstars-asc/
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.
Link to comment
https://forums.phpfreaks.com/topic/4977-order-by-goldstars-asc/#findComment-17538
Share on other sites

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.