Jump to content

Human readable alphanum.


PureEvil

Recommended Posts

Trying to pull a ton of data from a database that I would like ordered by a number that has been assigned to that data by the end user. IE 1,2,3,4,5,6

 

I'm using mysql_query("SELECT * FROM BLEH WHERE BLEH='BLEH' ORDER BY NUM ASC");

 

now when it prints out I get 0,1,10,11,12,13,14,15,16,17,18,19,2,20

 

I need to have it read as 0,1,2,3,4,5,6,7 etc etc...

 

Ideas?

 

Thanks in advance...

 

Me.

Link to comment
Share on other sites

Is the field defined as a character (varchar, text, char) or a number? If it is a character that is the correct ascii sort, to get what you want, make the field a number (int).

 

Ken

301458[/snapback]

 

 

I thought of that but I need it to be alphanumbaric.

 

because it might end up being A1, A7, A2 someday

 

Link to comment
Share on other sites

So how do you want it to sort these values:

 

1,11,2,20,A1,A20,A2 ?

 

If you have these values you *have* to do an alpha sort. If I were you I would make the field numeric and forget about what it *might* be in the future. Either that or left zero fill your data before sticking it into the database:

 

0001

0011

0002

00A1

 

Etc.

 

Good luck.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.