Hello All.

Is there any syntax for getting fields in a column in an alphabetical order in mysql?

See, for example...
I have a two column with "NAME & NUM".
NAME NUM
BHANU 6
KIRAN 3
ADAPA 8
CHANDU 7

I need to get the names in alphabetical order.
There is one syntax : select NAME from tablename orderby NUM;

I don't need this syntax.
Without having these kind of Syntaxes, it should display directly.
Help needy.

select NAME from tablename order by name;

hi
if you want albhabet name than you should use naa order by name
But i dont know another way

select NAME from tablename order by NAME;

Thanks

You could also have them bothlisted alpabetically.

SELECT name, num FROM tablename ORDER BY name, num

That might give you:

+------+-----+
| name | num |
+------+-----+
| Abc  |   1 |
| Abc  |   2 |
| Abc  |   4 |
| Bbc  |   2 |
| Bbc  |   5 |
| Cbc  |   3 |
| Cbc  |   7 |
+------+-----+

I think there is no other way in SQL to fetch the results in alphabetical order other than the "ORDER BY" phrase.

Thank u Friends.. now its solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.