To obtain the table name using a SELECT statement, use "information_schema.tables". Let's look at an example where we have a database with 3 tables. Syntax to get all table names with the help of SELECT statement.
SELECT Table_name as TablesName from information_schema.tables where table_schema = 'yourDatabaseName';
Use database "test" and apply the above syntax to get the table name using SELECT
mysql> use test; Database changed mysql> SELECT Table_name as TablesName from information_schema.tables where table_schema = 'test';
Output the names of the three tables.
+--------------------+ | TablesName | +--------------------+ | destination | | myisamtoinnodbdemo | | originaltable | +--------------------+ 3 rows in set (0.00 sec)
The above is the detailed content of Get table name using SELECT statement in MySQL?. For more information, please follow other related articles on the PHP Chinese website!