Jump to content

How to sort data from a table in alphabetical order?


angel1987

Recommended Posts

I am tired of searching online because everywhere it says use ORDER BY ..... ASC | DESC.

 

But that does not work for ordering data in alphabetical order. I don't understand how come that is working for so many people?

 

My query is:

"SELECT * FROM categories WHERE parentid = '$getid'";

 

I am listing categories on left side bar and there are more than 70 categories. I want them to appear in alphabetical order starting from A - Z.

 

I know there is some different syntax in sql query for ordering data alphabetically because i saw it once and it worked but i just forgot where i read it and now i am lost.

Your data probably contains white-space/non-printing characters (spaces, carriage-returns, nulls, line-feeds, ...) that is causing it be sorted out of order.

 

Where did your data originate and how did it get inserted into your table?

 

There are literally millions of php based web sites that use ORDER BY in queries that work. Had you stated or shown what results you are getting in your first post in this thread (where it belonged), you could have gotten an answer quicker, rather than playing around with what problem you actually are having.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.