Reputation: 1813
I want to check whether a table is in the database or not. So what is the MySQL query to check whether a table is in the database or not ?
Upvotes: 0
Views: 1260
Reputation: 4170
you should try with database_name and table_name also..
SELECT count(*)
FROM information_schema.tables
WHERE table_schema = 'db_name'
AND table_name = 'table_name'
will return you 1 if exists else 0
Upvotes: 1
Reputation: 15464
SELECT count(*) FROM information_schema.TABLES where TABLE_SCHEMA='dbname' and table_name='tblname'
Upvotes: 0
Reputation: 6403
SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'MyDataBase'
Upvotes: 1