有关更新的MySql错误

时间:2017-06-23 10:55:56

标签: mysql

我应该怎么做这个错误?这是我的问题:

UPDATE person  
SET 
  Name = '$Name', 
  Address = '$Address', 
  Email = '$Email', 
  Telephone = '$Telephone',  
WHERE Id = '$Id'; 

但在执行时会出现这种错误:

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 'WHERE Id = '$Id' at line 2

1 个答案:

答案 0 :(得分:3)

问题在这里

,  WHERE Id

他们是查询中WHERE之后的额外逗号,将其删除。所以查询就像:

"UPDATE person  SET Name = '$Name' , Address = '$Address' , Email = '$Email' , Telephone = '$Telephone'  WHERE Id = '$Id' ;"