此查询的格式好,在调试时我看到更新的值,但只显示此消息{"Invalid column name 'Mohannad' "}
,请帮助我们
UPDATE Employee
SET Name =Mohannad
, Age=22
, GenderID =1
, CountryID=1
, Mobile=8765
FROM Employee
INNER JOIN Country ON Employee.CountryID = Country.CountryID
INNER JOIN Gender ON Employee.GenderID = Gender.GenderID
WHERE EmployeeID=1 ;
SELECT Employee.EmployeeID, Employee.Name, Employee.Age, Employee.GenderID, Gender.GenderName, Employee.CountryID, Country.CountryName, Employee.Mobile
FROM Employee
INNER JOIN Country ON Employee.CountryID = Country.CountryID
INNER JOIN Gender ON Employee.GenderID = Gender.GenderID
答案 0 :(得分:3)
你需要Mohannad周围的报价:
SET Name='Mohannad'
如果没有引号,数据库引擎会假定它是列的名称。
如果您在程序中生成此查询,则应使用预准备语句,而不仅仅是在名称旁边添加引号,以避免错误和注入。
答案 1 :(得分:3)
尝试使用此代码
SET Name='Mohannad'
答案 2 :(得分:0)
Monhannad应该在引号中
UPDATE Employee
SET Name = 'Mohannad', Age=22, GenderID =1, CountryID=1, Mobile=8765
FROM Employee
INNER JOIN Country ON Employee.CountryID = Country.CountryID
INNER JOIN Gender ON Employee.GenderID = Gender.GenderID
WHERE EmployeeID=1 ;