我的印象是列的默认顺序是内部 mysql 顺序,但出于某种原因描述表并选择 column_name 给了我完全不同的顺序。
如何将 ORDER BY 设置为与“描述表”(“默认”表顺序 - 不是按名称)相同?
Server version: 8.0.12 MySQL Community Server - GPL
mysql> describe assetType;
+-------------+-------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+-------------+------+-----+---------+----------------+
| assetTypeID | int(11) | NO | PRI | NULL | auto_increment |
| assetName | varchar(45) | YES | | NULL | |
+-------------+-------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
mysql> SELECT column_name FROM information_schema.columns WHERE table_name='assetType';
+-------------+
| COLUMN_NAME |
+-------------+
| assetName |
| assetTypeID |
+-------------+
2 rows in set (0.00 sec)
ORDINAL_POSITION 字段可以提供帮助