Forum Moderators: coopster

Message Too Old, No Replies

Mysql order by 2 different variables.

         

dkin

4:37 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



I have a list of quests, each has three variables. Class, Race, Level. So far i have only ordered by level but now I would like to order by class and level. Sure there is a simple answer that is evading me.

Suggestions?

Cheers.

coopster

4:40 pm on Aug 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



SELECT * FROM table ORDER BY [dev.mysql.com] Class, Level;

dkin

5:39 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



I have changed it to that but now they are ordered like this

Elves Bard Level 1
Elves Bard Level 17
Elves Bard Level 2
Elves Bard Level 3
Elves Bard Level 4

I would like the 17 to come after the 4 obiously.

here is my sql

"SELECT * FROM nuke_quest_database order by Race, Level Asc",

anyone know, thanks in advance.

Cheers.

coopster

5:52 pm on Aug 5, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



OK, so you have the word "Level" in every column. You are bumping into what is called "natural ordering". Yeah, this has come up before...

[webmasterworld.com...]
[webmasterworld.com...]
[webmasterworld.com...]

If possible, I would eliminate the word "Level" from the column entry first. It is duplicated data, over and over again in your file. If that is not an option, you'll have to use some fancy footwork to get the sorting done. See if a couple of those links give you some ideas.

dkin

6:37 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



Seems multiplying by * 1 has done the trick, thanks coop.

Cheers