mysql:显示表-定义列名称 [英] mysql: SHOW TABLES - define column name
问题描述
我正在用'LIKE'做一个mySQL'SHOW TABLES'。例如:
显示类似 address_%的表
...返回以'address_'开头的所有表。
返回的表名的列名称为
Tables_in_username_users(address_%)
是否可以通过以下方式定义此列的名称: SHOW TABLES命令(例如地址表)?
这不仅容易,而且如果我更改了 like搜索条件,则列名也会更改,这在用PHP处理结果时是有问题的,因为like值是关联数组中的名称,而我希望有一个已知的列名?
给出一个特定的例如,如下所示:
===编辑后的问题===
任何混乱的警钟。 / p>
如果我说:
显示类似 address_%的表
我得到返回表的列表,即:
Tables_in_username_addresses(address_%)
address_13e625c01bea04b1d311
address_147e 32243c710542fb43
address_4f83b2740fc4f038775a
我的问题是,如何指定列名称和不要让它叫做'Tables_in_username_addresses(address _%)'
您可以自己查询信息模式:
SELECT table_name AS address_tables
FROM information_schema.tables
WHERE table_name像'address_%';
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_%)'
You could query the information schema yourself:
SELECT table_name AS address_tables
FROM information_schema.tables
WHERE table_name LIKE 'address_%';
这篇关于mysql:显示表-定义列名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!