Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 339
H. Ferrence Avatar asked May 18 '11 14:05

H. Ferrence


2 Answers

mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`') or die(mysql_error());
like image 68
Emmerman Avatar answered Sep 20 '22 13:09

Emmerman


You should use backticks instead of double quotes like this:

mysql_query('DROP TABLE IF EXISTS `dbName`.`tableName`');
like image 25
Kris Avatar answered Sep 20 '22 13:09

Kris