I would like to check if several tables exist in a database, and return a easy to understand return, I know you can check if a single table exists by running

show tables like "foo";

but is there something that could check more than one, and could return something that is not a list of tables that exists since there are more than a dozen that needs to be checked.

Perhaps counting the found tables?

1 Answer 1


Perhaps this is better solution for you:

SELECT COUNT(*) AS tables_found_count
FROM `information_schema`.`tables` 
WHERE `TABLE_SCHEMA` = 'database_name' AND
`TABLE_NAME` IN ('table1', 'table2')

It returns the count of found tables. Please list the tables in brackets and specify your database name instead of database_name.


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.