Last post Sep 19, 2018 01:24 AM by oned_gk
Sep 18, 2018 07:52 PM|slimbunny|LINK
How do I update multiple rows with 2 inner joins?
SELECT Emp.ID , Emp.field2, TableB.field3, TableC.NOTES FROM Employee as Emp
INNER JOIN TableB ON Emp.ID =TableB.NewTechID
INNER JOIN TableC on TableC.ComputerID = TableB.NewTechID
The above states returns 40 rows each must be updated but ONLY the 40 rows
How do I create an update statement that uses both inner joins to update TableC.NOTES = "*** what you say ****"
Sep 18, 2018 07:57 PM|limno|LINK
Merge TableC tgt
SELECT Emp.ID , Emp.field2, TableB.field3, TableB.NewTechID
FROM Employee as Emp INNER JOIN TableB ON Emp.ID =TableB.NewTechID
) src on tgt.ComputerID=src.NewTechID
WHEN matched then
Set NOTES='*** what you say ****';
Sep 18, 2018 11:49 PM|slimbunny|LINK
Thank you for this example but it did not work; let me clean up and try again.
Sep 19, 2018 01:24 AM|oned_gk|LINK
In query designer is very simple, simply change type from SELECT to UPDATE then set tablec.notes new value
AFAIK SImpy change from SELECT .... to Update TableC set Notes = 'newvalue' or
Update TableC set Notes = 'newvalue' ...
Update TableC set Notes = TableB.Fieldname