How to update the contents of a table with contents of another table
I guess this one’s straight forward for medium/experts, but for me its not trivial. Every time I need to do it I look it up because the solution doesn’t come to my mind.
So, the idea is to update a column from TABLEA with data coming from a column in TABLEB, there’s, of course, a join between the two tables.
SET b = (SELECT b1 from TABLEB WHERE TABLEB.a1 = TABLEA.a )
WHERE EXISTS (SELECT 1 from TABLEB WHERE TABLEB.a1 = TABLEA.a)
Posted in Databases
. Bookmark the permalink
. RSS feed
for this post.
Leave a trackback