update table when condition satisfied.

  • Thread starter Thread starter musa.biralo
  • Start date Start date
M

musa.biralo

I have a very simple problem again... (it took me 5+ hours and i
haven't figure it out and i know it should be very simple)

TableAA
ColN Col2 Col3
Row Pat1 0 123
Row Pat1 1 234
Row Pat2 0 456


TableBB (I am trying to update where Col2 =0 and (TableAA.ColN
=TableBB.ColN)) So, my final TableBB becomes

ColN Col2 Col3
Row Pat1 0 123
Row Pat2 0 456


I not able to make my SQL statement right... Please help me...

Thanks.
musa.biralo
 
UPDATE TableBB
SET TableBB.Col3 =
(SELECT TableAA.Col3
FROM TableAA
WHERE TableAA.Col2 = TableBB.Col2 AND
TableAA.ColN = TableBB.ColN)
WHERE TableBB.Col2 = 0;
 
Thanks that was helpful.
musa.biralo


UPDATE TableBB
SET TableBB.Col3 =
(SELECT TableAA.Col3
FROM TableAA
WHERE TableAA.Col2 = TableBB.Col2 AND
TableAA.ColN = TableBB.ColN)
WHERE TableBB.Col2 = 0;
 
Back
Top