Page 1 of 1

alphabetical order

Posted: Mon Apr 07, 2003 6:42 pm
by m3mn0n
In this new database I created I have to organize some things that require A LOT of cell colums. I inserted all of them into my database from a peice of paper that i had them written on. Now I did the insertions in no special order, but I want now to organize them all in alphabetical order. I'm wondering if this is possible.

I did a search on it but to no preval...

Thanks in advanced. :)

Posted: Tue Apr 08, 2003 4:03 am
by twigletmac
You can use ORDER BY fieldname to order by a particular field - it'll sort a text field alphabetically.

http://www.mysql.com/doc/en/SELECT.html

But are you trying to permanently reorganise the order?

Mac

Posted: Tue Apr 08, 2003 6:27 am
by m3mn0n
I could do that for the output which I know how to do, but yea I need to know how to make the changes to the database itself not the output of the database.

Posted: Tue Apr 08, 2003 6:36 am
by twigletmac
What does the table look like?

You may be able to copy the data to a temp table in the order you want using INSERT...SELECT:
http://www.mysql.com/doc/en/INSERT_SELECT.html
and then delete the old table and rename the copy.

Mac

Posted: Tue Apr 08, 2003 9:32 am
by hedge
Not sure what you mean. A DB table does not have any order. When you select it back it is essentially random.

It may appear ordered, but won't stay that way when deletes/inserts happen then the deleted rows are re-used by the new inserted rows. Also when the table extends new data could be anywhere on the disk. The only way to guarantee the output order is the order by clause.

edit:

should have said, this is with the db's (Oracle, sybase, etc.) I have used. Maybe some out there do store it in order.

Posted: Wed Apr 09, 2003 2:15 am
by m3mn0n
Image

I highlighted the first letters of the coloumns. That is what i want in alphabetical order. It's for organizational reasons, that is just a few of many. I just can't seem to find a way how. :?

Posted: Wed Apr 09, 2003 2:21 am
by twigletmac
Ah, sorry thought you meant you wanted to order the data as opposed to the columns.

Try this:
http://www.mysql.com/doc/en/Change_column_order.html

Mac

Posted: Wed Apr 09, 2003 10:02 am
by hedge
yep, so did I. Probably have to re-create the table.

Posted: Thu Apr 10, 2003 11:12 pm
by m3mn0n
This is nice, very nice. Especially when involving data inside the table but since my table is brand spankin' new, is kinda defeats the whole purpose. :?


:wink: thanks though! =)