SQL SERVER 2008 有两张表,需要将表A的一列数据 更新到表B,需要数据ID相对应,即通过主键关联两张表
发布网友
发布时间:2022-05-04 11:22
我来回答
共2个回答
热心网友
时间:2023-10-22 09:22
SQL语句如下:
update a
set a.pic_left=b.pic_left
from
PIC..T_Vehicle2 a
inner join yzdb..T_Vehicle b on a.id_vechile=b.id_vechile
热心网友
时间:2023-10-22 09:22
SQL语句如下:
update a
set a.pic_left=b.pic_left
from
PIC..T_Vehicle2 a
inner join yzdb..T_Vehicle b on a.id_vechile=b.id_vechile
热心网友
时间:2023-10-22 09:23
update PIC..T_Vehicle2
set pic_left = b.num
from PIC..T_Vehicle2 t,yzdb..T_Vehicle
where t.id_vechile=b.id_vechile
and exists (select 1 from T_Vehicle b where t.id_vechile=b.id_vechile)
and pic_left is null
热心网友
时间:2023-10-22 09:23
update PIC..T_Vehicle2
set pic_left = b.num
from PIC..T_Vehicle2 t,yzdb..T_Vehicle
where t.id_vechile=b.id_vechile
and exists (select 1 from T_Vehicle b where t.id_vechile=b.id_vechile)
and pic_left is null
热心网友
时间:2023-10-22 09:22
SQL语句如下:
update a
set a.pic_left=b.pic_left
from
PIC..T_Vehicle2 a
inner join yzdb..T_Vehicle b on a.id_vechile=b.id_vechile
热心网友
时间:2023-10-22 09:23
update PIC..T_Vehicle2
set pic_left = b.num
from PIC..T_Vehicle2 t,yzdb..T_Vehicle
where t.id_vechile=b.id_vechile
and exists (select 1 from T_Vehicle b where t.id_vechile=b.id_vechile)
and pic_left is null