I need to be able to detect if the database and/or the table exists on a single query, to act accordingly. I have this fugly query working:
SELECT * FROM
(SELECT COUNT(*) AS `database`
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMATA.SCHEMA_NAME="database_name") AS foo,
(SELECT COUNT(*) AS `table`
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = "database_name"
AND table_name = "table_name") AS bar
This query returns:
database table
1 0
But... Maybe there is a better method out there.