Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alias to Show Tables MySQL Result

Tags:

sql

list

mysql

When executing SHOW TABLES FROM your_db_name_here inside MySQL, the result has Tables_in_{your_db_name_here} as its indexes. I'd like to change that, like this:

SHOW TABLES as _tables FROM mydb;

or something like

SELECT Tables_in_mydb AS _tables FROM (SHOW TABLES FROM mydb);

Any ideas?

like image 405
Marco Aurélio Deleu Avatar asked Jul 07 '12 20:07

Marco Aurélio Deleu


1 Answers

It's usually easier to interact with the INFORMATION_SCHEMA database:

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

Example:

SELECT TABLE_NAME AS _tables 
FROM INFORMATION_SCHEMA.TABLES 
WHERE TABLE_SCHEMA = 'mydb'
like image 112
Joshua Martell Avatar answered Oct 12 '22 23:10

Joshua Martell