Reputation: 1388
I need to get some specific tables in the database, sample.
SELECT table1, table2 table3 FROM data_base ORDER BY DESC;
I have found that I can do to get all tables: SHOW TABLES; But I want to bring me specific tables.
¿They know any way?
I found this way also:
SELECT TABLE_NAME AS tb_name
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME = 'city' AND TABLE_NAME = 'city'
AND TABLE_SCHEMA='test_offers';
But it shows one specific table if another conditional, then shows me many repeated tables.
Much appreciate your support!
Upvotes: 1
Views: 2656
Reputation: 1891
SELECT table_name
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME in ('city','table1','table2')
AND TABLE_SCHEMA in ('test_offers','tbl1',tbl2');
Other wise see this article for more information about this. http://dev.mysql.com/doc/refman/5.0/en/information-schema.html
Upvotes: 1
Reputation: 24959
You can read information from the INFORMATION_SCHEMA
database. It's columns make for fun perusing.
select table_name
from INFORMATION_SCHEMA.tables
where table_schema='so_gibberish'
and table_name in ('jiveturkey','items','casted_by')
order by table_name;
+-------------+
| TABLE_NAME |
+-------------+
| casted_by |
| items |
| jiveturkey |
+-------------+
Upvotes: 2