Can you DROP TABLE IF EXISTS by specifying database name with table?

H. Ferrence picture H. Ferrence · May 18, 2011 · Viewed 34.2k times · Source

I am trying to drop a table in a database with the following query statement:

mysql_query('DROP TABLE IF EXISTS "dbName.tableName"') or die(mysql_error());

But I keep getting an error. Does anyone know if specifying the dbName.tableName is invalid?

Answer

Emmerman picture Emmerman · May 18, 2011
mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`') or die(mysql_error());