Mysql - 如何为列指定别名


Mysql - How to Give Alias name for column

我正在从数据库中获取与查询字符串匹配的表列表。

我的查询

show tables like '%fit%'

输出

Tables_in_pdi (%fit%)

fit_types

在 PHP 中,当我获取这些时,我得到的输出为

Array ( [Tables_in_pdi (%fit%)] => fit_types )

如果无论如何都要为这些提供别名,这样我就很容易在 php 中获取数据

使用INFORMATION_SCHEMA数据库会更容易:

http://dev.mysql.com/doc/refman/5.0/en/tables-table.html

SELECT table_name FROM INFORMATION_SCHEMA.TABLES
  WHERE table_schema = 'DB_NAME'
  AND table_name LIKE '%fit%'