Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MySQL Sorting Problem

Status
Not open for further replies.

warik

Programmer
Jun 28, 2002
169
0
0
ID
Dear all,

What SELECT is the best for this sorting problem?

table mytable:

No | Name | ID
1 | aaa | 20
2 | bbb | 90
3 | ccc | 80
4 | ddd | 10



I would like to sort become like this :
Sort from name, but ID 90 will be the last. So it will be like this:

No | Name | ID
1 | aaa | 20
3 | ccc | 80
4 | ddd | 10
2 | bbb | 90


What I know to sort name with:
select * from mytable order by name.....
what next? or any other advice?

Thank you in advance.
 
Please don't cross-post.

Given that data, there is no sort order that can produce the exact output you have specified.

If you use "order by ID", you'll get:

4 | ddd | 10
1 | aaa | 20
3 | ccc | 80
2 | bbb | 90


Want the best answers? Ask the best questions: TANSTAAFL!!
 
Thank you sleipnir214 for your answer. I thought this problem also can be solved with php script except MySQL itselft. So I wrote at PHP Forum and MySQL Forum.
Anyway... thank's a lot.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top