istudent — 2004-07-02T14:17:53-04:00 — #1
I am looking for an SQL command that will sort the ID column in my database in ascending order.
matt_12511 — 2004-07-02T14:24:30-04:00 — #2
oops the correct response is on the post below.
redemption — 2004-07-02T14:27:02-04:00 — #3
istudent — 2004-07-02T14:37:56-04:00 — #4
I tried both and either of them worked. Do I have to put the table name in some where?
redemption — 2004-07-02T14:56:56-04:00 — #5
Yes, the ORDER BY clause comes after everything in the SQL statement.
matt_12511 — 2004-07-02T14:58:30-04:00 — #6
The entire SQL command is"
Select Field Names From Table Name ORDER BY [/I]ID Field Name[I] ASC.
Select * From Customers Order By CustomerID ASC
or Select CustomerID, CustFirstName, CustLastName From Customers Order By CustomerID ASC
PS. Do you have to have the ASC? or is it default?
redemption — 2004-07-02T15:01:34-04:00 — #7
Yes ASC (ascending) is the default, but I put it there so that there's no doubt about it next time when I read the SQL (I always can't remember which is the default).
istudent — 2004-07-02T15:02:45-04:00 — #8
What do I put for the conditions? I just want it to sort the whole table.
redemption — 2004-07-02T15:05:00-04:00 — #9
If you have no conditions, just leave it out.
istudent — 2004-07-02T15:10:05-04:00 — #10
I tried that. I changed the code to:
It does sort things, but only on the SQL query/queries page in phpmyadmin. When I got to the browse tab in phpmyadmin, nothing is changed.
redemption — 2004-07-02T15:13:37-04:00 — #11
I think you are mistaken in your understanding of databases. The records in a table are not sorted in any determinable way. So you can't say that this record is record 1, that one is record 2 in the table.
When you view the records in, say, phpmyadmin, there is no specific ordering given to the records. If you want to view the records in a specific order, use the ORDER BY clause in an SQL statement. However, you can't change the innate order because there is none.
istudent — 2004-07-02T15:21:32-04:00 — #12
Okay, I get it now. Thanks for all your help!