View Full Version : using phpmyadmin to order cols

08-22-2010, 08:15 PM

Is there a way to use phpmyadmin to order columns? Most of my tables do not have too many columns, but I have one or two with 30+ cols and I want phpmyadmin to list them alphabetically as opposed to the order in which they were stored/created. Is there a way to do this via phpmyadmin or with a query?


08-22-2010, 11:46 PM
To view them? Click the column title, I believe.

To search through them this way, use 'ORDER BY colname' in the query.

08-23-2010, 01:26 AM
Actually, what I meant to say was, how do you sort the fields in phpmyadmin. For example, when viewing a given table structure there will be a column for the names of the fields. What I want to be able to do is order the field names of the table alphabetically. Permanently, if possible.

08-23-2010, 02:21 AM
It seems that you can do this with the following:

$query="ALTER TABLE t1 MODIFY column1 text AFTER column2";

I have not tried it out just yet, but will soon.

I got the idea from this reference: http://forums.digitalpoint.com/showthread.php?t=825045

08-23-2010, 02:27 AM
Oh I see. Your question can be read two ways but now that you explained a bit more it seems obvious. Glad you found that. Never ran into this situation before. Interesting. I don't think phpmyadmin really has any tools for that though.