update a set a.timeA=b.timeA from ta as a,tb as b where a.关联条件=b.关联条件 and not exists(select 1 from tb where 关联条件=b.关联条件 and time1>b.time1) 你可以先使用下面的语句看一下更新是否正确。select a.timeA,b.timeA from ta as a,tb as b where a.关联条件=b.关联条件 and not exists(select 1 from tb where 关联条件=b.关联条件 and time1>b.time1)
update A set timeA = case when time1 is null then time2 when time2 is null then them1 when time1 < time2 then time2 else time1 end from A join B on A.id=B.id -- 假设A,B表以ID关联
update A set timeA = case when time1 is null then time2 when time2 is null then them1 when time1 < time2 then time2 else time1 end from b where A.关联关系=B.关联关系
update A set timeA = case when time1 is null then time2 when time2 is null then them1 when time1 < time2 then time2 else time1 end from b where A.关联关系=B.关联关系
set a.timeA=b.timeA
from ta as a,tb as b where a.关联条件=b.关联条件
and not exists(select 1 from tb where 关联条件=b.关联条件 and time1>b.time1)
你可以先使用下面的语句看一下更新是否正确。select a.timeA,b.timeA
from ta as a,tb as b where a.关联条件=b.关联条件
and not exists(select 1 from tb where 关联条件=b.关联条件 and time1>b.time1)
when time1 is null then time2
when time2 is null then them1
when time1 < time2 then time2
else time1 end
from A
join B on A.id=B.id -- 假设A,B表以ID关联
update A set timeA = case
when time1 is null then time2
when time2 is null then them1
when time1 < time2 then time2
else time1 end
from b
where A.关联关系=B.关联关系
update A set timeA = case
when time1 is null then time2
when time2 is null then them1
when time1 < time2 then time2
else time1 end
from b
where A.关联关系=B.关联关系