2016-06-21 66 views
0

我無法糾正問題Mysql的錯誤:在更新查詢

UPDATE tbl_delete SET delete='60' WHERE tablename='somereports' 

上面的代碼拋出錯誤以下錯誤:

Error in Updation Query
UPDATE tbl_delete SET delete='60' WHERE tablename='somereports'
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 'delete='60' WHERE tablename='somereports'' at line 1

回答

3

在mysql中刪除是reserved keyword必須在backtick。或更改列名這是不是在保留關鍵字列表

UPDATE tbl_delete SET `delete`='60' WHERE tablename='somereports' 

,或者您也可以前列名寫表名作爲

UPDATE tbl_delete SET tbl_delete.delete='60' WHERE tbl_delete.tablename='somereports' 
3

DELETE是MySQL中的保留關鍵字,所以它解析像一個關鍵字,而不是一個列名。 MySQL預期在DELETE關鍵字後面有效的DELETE語法,但它會「看到」等號(=)。把它換成``來修正這樣的錯誤:

UPDATE tbl_delete SET `delete`='60' WHERE tablename='somereports';