Jump to content


Photo

ORDER BY goldstars ASC


  • Please log in to reply
3 replies to this topic

#1 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 14 March 2006 - 09:29 PM

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
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 14 March 2006 - 09:33 PM

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 FROM tableName ORDER BY 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.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

#3 joecooper

joecooper
  • Members
  • PipPipPip
  • Advanced Member
  • 358 posts

Posted 14 March 2006 - 09:38 PM

great! that works, thanks...

i forgot the Thing for deaccending... opersite to ASC??
Signature:
[/a]
[a href="http://www.planet-so...=1999&lngWId=8" target="_blank"]EzLogin 1.0[/a]
[a href="http://www.essexracers.com" target="_blank"]Essexracers.com[/a]
Msn Messenger: joe@joeyjoe.co.uk

#4 annihilate

annihilate
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationUK

Posted 14 March 2006 - 09:47 PM

Use DESC to order descending
ORDER BY column_name DESC

Personal site: NewEnigma  |  Java and JSF Discussion




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users