|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hello,
My table looks like this this (tablename: test): --------------------------------------------- id name 1 A 2 C 3 B 4 D 5 Z 6 E --------------------------------------------- When i execute the query (select name from test) i end up getting the rows in order (i.e. A, C, B, D, Z and E). Now, say i want these rows in exactly the reverse order. Can i formulate any query for the same? So, the new query should output the names in the order (E, Z, D, B, C and A) which is exactly the reverse order. Thank you Neville |
|
#2
|
||||
|
||||
|
Use the ORDER BY statement to order your returned records.
Code:
SELECT * FROM test ORDER BY id DESC |
|
#3
|
|||
|
|||
|
A little twist...
Thanks for the response. Anyway, this is not exactly what i was looking for. Lets also assume that the id's are all jumbled up too. So, the new table data say looks like this.
My table looks like this this (tablename: test): --------------------------------------------- id name 2 C 6 E 3 B 5 Z 1 A 4 D --------------------------------------------- Now, say i need the sequence D, A, Z, B, E and C in one query. Even the ids are NOT in order so order by DESC wont work here. Thank you Neville |
|
#4
|
||||
|
||||
|
Basically, you need to have another field that is orderable - i.e. using numbers or letters. I'm not sure what else you're expecting to do.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Sql query help... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|