dimanche 1 février 2015

UPDATE table SET value which SELECT from other table


I need to update the column based on Table_1 and Table_2, and then SET the value which select from Table_3



UPDATE top(3) a
SET col_1 = col_2_FromTable3 // Problem here, Column select Table_3
FROM Table_1 a
INNER JOIN Table_2 b
on a.id = b.id
WHERE b.id = '11'


Table_1


ID | col_1


11 | null


11 | null


11 | null


11 | null


11 | null


Table_3


col_2


AA


BB


CC


Expected Result of Table_1 (Update top 3 records which select form Table_3)


ID | col_1


11 | AA


11 | BB


11 | CC


11 | null


11 | null





Aucun commentaire:

Enregistrer un commentaire