|
Author |
Message |
domuk
WebHelper
Joined: 15 Jan 2004
Posts: 91
|
Posted:
Wed Jun 02, 2004 10:56 am (20 years, 6 months ago) |
|
I am trying to sort my query results into their specific order and have run into a few problems.
I am using the “order by” statement with a mysql database and PHP
1) DATA: 1,2,3,4,5,6,7,8,9,10
Problem: It orders the above data 9,8,7,6,5,4,3,2,10,1 It
looks like the algorithm starts at the first character
in the string orders them and then goes to the
second character.
QUESTION: Is there a way to order the data so it gives
10,9,8,7,6,5,4,3,2,1?
2) I would like to order the list below, but it does not follow any numeric or alphabetical order. There however is an order to the individual letters, which is as below:
M=0
D=1
Vd=2
Ms=3
S=4
Hs=5
Mvs=6
Vs=7
The letters are stored in the database. Is there a way to order these using sql without changing the data stored in the database?
Hope you can help,
Dom. |
|
|
|
|
Daniel
Team Member
Joined: 06 Jan 2002
Posts: 2564
|
Posted:
Wed Jun 02, 2004 3:42 pm (20 years, 6 months ago) |
|
I don't think there's a solution to the second problem using an SQL command, however there is a solution to the first:
or Code: | ORDER BY column DESC |
|
________________________________
|
|
|
|
domuk
WebHelper
Joined: 15 Jan 2004
Posts: 91
|
Posted:
Wed Jun 02, 2004 5:29 pm (20 years, 6 months ago) |
|
Thanks Daniel.
I was using asc and desc.
The problem that I had was the database was set up to varchar when it should be tinyint. it works now. |
|
|
|
|
|
|
You cannot post new topics in this forum. You cannot reply to topics in this forum. You cannot edit your posts in this forum. You cannot delete your posts in this forum. You cannot vote in polls in this forum.
|
Page generation time: 0.123855 seconds :: 17 queries executed :: All Times are GMT
Powered by phpBB 2.0
© 2001, 2002 phpBB Group :: Based on an FI Theme
| |