I need to update a table column white the same data that currently exists in that column plus add data from one column from another table. The tables in question are in 3N.
I am attempting to do a complex update by concanting data from one column in a principle table into a column in an existing table.
update Catelog.Component SET Name = p.Number
FROM Catelog.Part p JOIN
Catelog.ComponentPart cp ON p.ID = cp.PartID JOIN
Catelog.Component c ON cp.ComponentID = c.ID
where p.BrandID = 1003
AND ct.Name='Door' + '|'+ Name;
If you’ll notice the Name column that I am setting I am resetting the data that already exists in that column plus prefixing the PartNumber.
Basically I need to prefix the existing data in the Name column with the part number from the part table.
Right now SQL is giving me the ambiguous error.
Plus, I do not think that the rows would be set correctly the way I’ve got this update structured.
What is the best way to do joined updates like this?
I’m not sure about where last Name belongs (from which table, it’s not clear)