Jump to content

number issue with ORDER BY


perky416

Recommended Posts

Hi Guys,

 

When im pulling data from my database and displaying it on my page, im using ORDER BY in my query to display the data in alphabetical order. When it comes to displaying data with numbers in it, it isnt ordering how i want it.

 

Example:

This is how it is currently ordering the data:

 

test1

test10

test11

test12

test13

test14

test15

test16

test17

test18

test19

test2

test20

 

and so on....

 

How would i go about getting it to display like:

 

test1

test2

test3

test4

test5

test6

test7

test8

test9

test10

test11

test12

 

and so on....

 

Thanks

Link to comment
Share on other sites

If your data constitently has the same name prefixing the integers, then you can use something like:

ORDER BY SUBSTRING(column_name,5);

Otherwise, it will be a bit more complicated.

Link to comment
Share on other sites

Hi guys,

 

Im completely at a loss with this.

 

Im working on a domain script, so people could add domains such as 10.com, test1.com, ismell.com, so it will never be a fixed format.

 

Im tearing my hair out lol. I cant seem to find anything on google about this to work with.

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.