Possible Duplicate:
MySQL - check if table exists without using “select from”
Can I rely on this query to find out if tables in the specified database exists or there may be some restrictions?
SELECT
`information_schema`.`TABLES`.`TABLE_NAME`
FROM
`information_schema`.`TABLES`
WHERE
`information_schema`.`TABLES`.`TABLE_SCHEMA` = 'my_database_name'
AND `information_schema`.`TABLES`.`TABLE_NAME` IN (
'table_name',
'table_name',
'table_name',
'table_name',
'table_name',
'table_name'
)
P.S. I do not need to create a table, and just need to check whether it exists or not.
Or you could use this (longer query).
SELECT count(*)
FROM information_schema.tables
WHERE table_schema = 'databasename'
AND table_name = 'tablename'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With