mysql get table column names in alphabetical order

后端 未结 3 672
情深已故
情深已故 2020-12-09 03:22

Is it possible to query a MySQL database to get the column names of a table in alphabetical order? I know that

SHOW COLUMNS `table_name`;

3条回答
  •  醉酒成梦
    2020-12-09 03:48

    Every field was listed twice until I used group by column name

     select c.COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS c 
     where c.TABLE_NAME = `'tbl_name'` 
     group by c.column_name 
     order by c.column_name
    

提交回复
热议问题