请各路大神看看,sql应用
两张表,现要把b表里的b字段插入到a表中的a字段,条件是a表的c字段与b表的c字段相同。
请问此语句怎么写?
------解决方案--------------------
UPDATE A
SET A.a=B.b
FROM a AS A
JOIN B AS B ON A.c=B.c
------解决方案--------------------
update x
set x.[a]=y.[b]
from a表 x
inner join b表 y on x.[c]=y.[c]
------解决方案--------------------update x
set x.n1=y.total_no_of_days
from x inner join (select staff_no,sum(total_no_of_days)total_no_of_days from y
where leave_code=24 group by staff_no) y on x.staff_no=y.staff_no