mysql: SHOW TABLES - define column name

1.1k views Asked by At

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

There are 1 answers

5
Mureinik On BEST ANSWER

You could query the information schema yourself:

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