oracle下:
update housea a set a.extendinfo=(select b.extendinfo from houseb b where a.houseid=b.houseid)
where a.isimage=1 and a.extendinfo is null and exists(select 1 from houseb b where a.houseid=b.houseid)
sqlserver下:
update a set a.extendinfo=b.extendinfo from housea a,houseb b where a.houseid=b.houseid
两者各不通用.第二种更简洁
下面是一个存储过程,为更新某条件之外的一部分数据.
alter procedure TQ_leasehouse
as
declare @code varchar(20)
declare cc cursor for select managercode from mlsheadcompany where companycode=201001472
open cc
fetch next from cc into @code while (@@FETCH_STATUS=0)
begin
declare @updnum int
select @updnum = COUNT(1) from rent_house.dbo.house_lease_sh_mls where agentcode=@code and registdate>CONVERT(datetime,GETDATE(),120)
update a set registdate=GETDATE() from (select * from (select registdate,ROW_NUMBER() over(order by registdate) rn
from rent_house.dbo.house_lease_sh_mls where agentcode=@code and registdate<CONVERT(datetime,120)) b where rn<120-@updnum) a
fetch next from cc into @code
end
close cc
deallocate cc
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。