PDA

View Full Version : using phpmyadmin to order cols



james438
08-22-2010, 08:15 PM
Hi,

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?

Thanks

djr33
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.

james438
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.

james438
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";
$exec=mysql_query($query,$connection);

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

djr33
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.