I have a highscore list for a game that has 3 modes easy, normal or hard In the DB the row is : Score - Mode 350 normal 300 easy 300 hard 300 normal I want to list the games by highest score yet still have the modes grouped together. For instance, all Hard mode scores will be listed from highest to lowest then all normal then all easy. So when done would be Score - Mode 300 hard 350 normal 300 normal 300 easy Any Idea what the query would be to do this. I have tried order by score, mode but that doesn't work. Any help would be great! Thanks
Use 2 fields in your order by clause: ...ORDER BY Mode ASC, Score DESC... However, because you are sorting the Mode and it is a text field, it is going to put them in order alphabetically--so 'hard' will always appear between 'normal' and 'easy', no matter which way you sort it. To force it to be at the top or bottom you would need to make a new 'Mode' table and assign ranks to them (i.e hard has rank 1, normal rank 2, etc.) then you join the tables and order them by that rank.
what about a PHP script that does all that once it pulls all the database information. then it would just be less-than or greater-than comparisons to the Modes of hard, normal, easy. That would sort all Hard modes first by choosing all the hard modes first For Each, While -- etc. Have a PHP script pull all the Mode of Hard first. Then have the script sort them based on highest and lowest integer. and stack them nicely as you want. Do the same thing for Normal and Easy. That way it doesnt matter how you store them in the database.
@plog ok I wil try it thanks @ezprint2008 wouldn't that be more than one query though? EDIT: Plog it worked like a charm! Thanks again!
You can combine queries Here is an example one i may have Select USERNAME as user, PASSWORD as pass, EMAIL as useremail FROM members WHERE whatever Then u can access it all Or look up joint queries