如何写这样的代码
A表
userid
user_type
B表
userid
user_type
现在想根据userid字段将A表的user_type更新成B表的user_type值,该如何写这样的语句
望指教,谢谢
------解决方案--------------------update a set user_type=( select user_type from b where b.userid= a.userid ) where
a.userid in ( select userid from b )
------解决方案--------------------UPDATE Table2
SET Table2.ColB = Table1.ColB
FROM Table2
INNER JOIN Table1
ON (Table2.ColA = Table1.ColA);
------解决方案--------------------update tableA set a.user_type=b.user_type where a.user_id=(select b.user_id from tableB)
------解决方案--------------------update a set a.user_type=b.user_type
where a.user_id
=(select b.user_id from b)
------解决方案--------------------merge into a
using b
on (a.user_id = b.user_id)
when matched then update set a.user_type = b.user_type