I have a Linux server with MySQL 5.0 (5.0.67) installed.
In that server, I have a database that has a table with many fields (around 60).
It would be convenient for me to get a list of those fields ordered by
field / column name. Unfortunately, a "DESC tablename ("DESCRIBE
tablename") command, in "MySQL monitor" (the MySQL command line
client) returns a table with that table fields, but the fields appear
in a strange order. I'm guessing this strange order can be the order
given by the "CREATE TABLE" command that was used to create that
The first thing I tried was to write "DESC tablename ORDER BY Field".
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near 'ORDER BY Field' at line 1
So, I went to read the online documentation about the DESCRIBE command
and the SHOW COLUMNS (or its synonym SHOW FIELDS) command:
MySQL :: MySQL 5.0 Reference Manual :: 12.3.1 DESCRIBE Syntax
MySQL :: MySQL 5.0 Reference Manual :: 126.96.36.199 SHOW COLUMNS Syntax
Unfortunately, I'm NOT finding, in those 2 web pages, any hints about
sorting the list of fields by any criteria.
I did some "google" searches about this, but I didn't find any
relevant results (maybe I'm using the wrong keywords for my searches).
So, I'm asking this: does anyone know a MySQL command to get this list
of fields sorted by field name? Or do you achieve this result by other
means (e.g: using some GUI tool, copying the list of fields to a text
file and sorting it, writing some script...)?
Thanks in advance!
Ricardo Dias Marques
lists AT ricmarques DOT net