Rename a MySQL table using SQL statement

Mar 12, 2012   //   by phpfreelancer.biz   //   Blog, MySQL Tutorial  //  No Comments

I want to rename an existing table using SQL statement:

I have already tried:

mysql_query("RENAME '$renameFolder' TO '$newName'")

But getting the error message

"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax"

removing the quotes  in $renameFolder and $newName

Here’s the code

mysql_query( "RENAME TABLE `" . $renameFolder . "` TO `" . $newname . "`" );

Leave a comment

Share This Post

RSS Wordpress News