mysql: SHOW TABLES - define column name

天大地大妈咪最大 提交于 2019-12-11 00:32:18

问题


I am doing a mySQL 'SHOW TABLES' with a 'LIKE'. For example:

show TABLES like 'address_%'

... to return all tables that start with 'address_'. That works fine.

The table name that is returned has a column name of

Tables_in_username_users (address_%)

Is there a way to define the name of this column in the 'SHOW TABLES" command (to say 'address tables')?

This is not only easier but if I change the 'like' search criteria the column name changes and this is problematical when processing the result in PHP as the like value is the name in the associative array and I would prefer to have a known column name?

TO give a specific example, as requested below:

=== Edited Question ===

Apolgies for any confusion.

If I say:

show TABLES like 'address_%'

I get a list of tables returned. That is:

Tables_in_username_addresses (address_%)    
address_13e625c01bea04b1d311
address_147e32243c710542fb43
address_4f83b2740fc4f038775a

My questions is, how do I dictate the name of the column name and not let it be called 'Tables_in_username_addresses (address_%)'


回答1:


You could query the information schema yourself:

SELECT table_name AS address_tables
FROM   information_schema.tables
WHERE  table_name LIKE 'address_%';


来源:https://stackoverflow.com/questions/46201765/mysql-show-tables-define-column-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!