Reputation: 13
Format for this query ok, when debugging it I see the value for updating but only show me this message {"Invalid column name 'Mohannad' "}
, please help me guys
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
Upvotes: 1
Views: 1132
Reputation: 4737
Monhannad should be in quotes
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 ;
Upvotes: 0
Reputation: 382132
You need quotes around Mohannad :
SET Name='Mohannad'
Without quotes, the database engines presumes it's the name of a column.
If you're generating this query in a program, you should use prepared statements, not just put quotes around the names, to avoid bugs and injections.
Upvotes: 3