I have these tables:
tblPart
ID, field1, field2, ecc
tblUserFreeProperty
ID_tblPart, ID, identname, val
I need to write a query to update tblUserFreeProperty
, but only the val filed when tblPart.ID = tblUserFreeProperty.ID
and identname
has a specific value.
In the database, identname
has one of 8 possible values, and I need to update all of them.
I have wrote a query for only one value at time:
UPDATE tblUserFreeProperty
SET val = N'??_??@True;'
FROM tblUserFreeProperty
LEFT OUTER JOIN tblPart ON tblUserFreeProperty.id = tblPart.id
WHERE tblUserFreeProperty.id = N'3'
AND (tblUserFreeProperty.identname = N'DSR_Mag.Gestito')
Is there a way to write the update query for all 8 different values at the same time?
Added explanation: I need a query like this:
UPDATE tblUserFreeProperty
SET val1 = N'??_??@True;, val2 = N'??_??@False;', val3 = N'5', val4 = N'BK',...val8
FROM tblUserFreeProperty
LEFT OUTER JOIN tblPart ON tblUserFreeProperty.id = tblPart.id
WHERE (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'DSR_Mag.Gestito'))->SET Val1
OR (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'DSR_Mag.Done'))->SET Val2
OR (tblUserFreeProperty.id = N'3' AND (tblUserFreeProperty.identname = N'Something Else'))->SET val3
I hope it is more clear