Search code examples
phpmysqlsql-drop

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


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?


Solution

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