I have one database which contains two tables:
–October2012_ID which contains two columns:
a) OldId
b) NewId
–BNP which contains two columns also:
a)BankId
b)OrbId
I need to update the BNP table by replacing values contained into the two columns IF these values are available in the column OldId located into the table October2012_ID. And if this is the case, I need to update the columns in BNP by the value of NewId.
So:
Update BNP
SET BNP.**BankId**=October2012_Id.NewId
where BNP.**BankId**=October2012_Id.OldId and October2012_Id.**BankId** is not null
And also:
Update BNP
SET BNP.**OrbId**=October2012_Id.NewId
where BNP.**OrbId**=October2012_Id.OldId and October2012_Id.**OrbId** is not null
I’m a noob in SQL, so could you help me please ?
You can try to add
orbetween your conditions: