update rs_jbqk set (c31,d3,d4)=(select c4,c3,c2 from
(select aa.c1,aa.c4,aa.c3,aa.c2 from aa,rs_jbqk where aa.c1=rs_jbqk.c1
union
select c1,c31 as c4,d3 as c3,d4 as c2 from rs_jbqk where c1 not in
(select c1 from aa)) b
where rs_jbqk.c1=b.c1);aa是一个临时表,根据工号,把aa的值属值到rs_jbqk中的三个字段.
执行的时候没错,可时间(d3,d4)没有被修改啊
(select aa.c1,aa.c4,aa.c3,aa.c2 from aa,rs_jbqk where aa.c1=rs_jbqk.c1
union
select c1,c31 as c4,d3 as c3,d4 as c2 from rs_jbqk where c1 not in
(select c1 from aa)) b
where rs_jbqk.c1=b.c1);aa是一个临时表,根据工号,把aa的值属值到rs_jbqk中的三个字段.
执行的时候没错,可时间(d3,d4)没有被修改啊
aa表中有十条记录,rs_jbqk中有100条记录.
实现:修改rs_jbqk中aa中有的十条记录,没有的就保持原来的值
c31=(ISNULL(SELECT c4 FROM (...) b WHERE rs_jbqk.c1=b.c1),'0'),
d3=(ISNULL(SELECT c3 FROM (...) b WHERE rs_jbqk.c1=b.c1),'0'),
c2=(ISNULL(SELECT c2 FROM (...) b WHERE rs_jbqk.c1=b.c1))2、select c1,c31 as c4,d3 as c3,d4 as c2 from rs_jbqk where c1 not in
(select c1 from aa)//个人觉得没必要
这样不知行不行?