For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > June 2006 > mysql ORDER BY problems









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mysql ORDER BY problems
Rob W.

2006-06-18, 6:57 pm

Ok, here's what i got in my mysql db. I got a table listed with numbers as follows

1
2
3
4
5
6
7
10
11
12
13
14
15
16
17
18
19
20
21
22
25

These numbers I can display fine. I'm using ..

$query="SELECT * FROM db ORDER BY numbers ASC";

Right now it displays it as

1
10
11
12
......
2
22
23
25
.....
3
4
5
6
7

Is there a way with my mysql query so that I can list the numbers in correct order?

Any help is appricated.

- Rob
J. Alejandro Ceballos Z. -JOAL-

2006-06-18, 6:57 pm

are they defined as integer or varchars (string)?

try
a) exchange field definition varchar / integer
b) order by length(number) and later by number
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com