0

Can anyone help me find the syntax error in this code?

    $sql = "ALTER TABLE self_downloads DROP id; ALTER TABLE self_downloads AUTO_INCREMENT = 1; ALTER TABLE self_downloads ADD id int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;";

Thank you very, John

  • As your converting all queries into a single string there must be termination of each query with `;`. Your missing `;` at the end of each query. – Sasikumar Sep 26 '16 at 04:49
  • $sql = "ALTER TABLE `self_downloads` DROP `id`;"; $sql.= "ALTER TABLE `self_downloads` AUTO_INCREMENT = 1;"; $sql.= "ALTER TABLE `self_downloads` ADD `id` int UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;"; – Alive to die - Anant Sep 26 '16 at 04:49
  • That code returns this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ALTER TABLE self_downloads AUTO_INCREMENT = 1;ALTER TABLE self_downloads ADD id ' at line 1. – John Finberg Sep 26 '16 at 04:51

0 Answers0