1

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!

3
  • what's the purpose behind this? Commented Nov 3, 2015 at 5:05
  • you can put table names like table_name in ('city','table1','table2') to get multiple tables Commented Nov 3, 2015 at 5:07
  • I want to add from an administration panel, a menu list with the option to add multiple records to a table specified in the database, to avoid having to climb a Excel, for example up some specific users, which need to add the ID, name, email etc ... From an excel I can export an organized structure separated by commas, 123123; Username; [email protected] by explode PHP I can count the number of columns and an array insert data. This we will do to multiple tables separately. Commented Nov 3, 2015 at 5:10

2 Answers 2

2

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  |
+-------------+
Sign up to request clarification or add additional context in comments.

2 Comments

You mean that worked for you too? I knew someone else out there had a jiveturkey table ;)
It works perfectly :), look at several post but showed an example for specific tables, just to get all tables. Thank you.
1
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

3 Comments

This example works but it brings me a lot of details and characteristics of the tables. Similarly, thank you very much.
Use table_name instead of *.
If you can show an example would be perfect and not so experienced user can understand it better. But in the commentary Drew, the example works perfect.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.