对a表循环处理,比如处理到 a.id = 188了 ,(应该以变量代替了) (你用的是什么数据库啊,我用SQL Server的存储过程哈,你上面是什么数据库的语法?)If Exists(select * from b.maintaindate > GetDate() where clientid = 188 ) update 表a.col = 1 where id=188 ElseIf Exists(select * from b.maintaindate is not Null ) update 表a.col = 0 where id=188 Else Begin date = b.singdate + time(某种方法处理,让这两个能够相加) --某种方法处理,你自 --己想了哈 -- 这里要好好处理了,你要得到 date的值,可能这里比较麻烦吧 If date > GetDate() update 表a.col = 1 where id=188 Else update 表a.col = 0 where id=188 End
我要得到b表中的最晚时间并与当前时间作比较,然后根据比较的结果更新a表。
select top 1 * from 表b order by 日期 desc
if(表b.maintaindate != null)
for(i=0;i<记录总数,i++)
b.maintaindate = 最晚时间
比较:if (b.maintaindate >= datatime.now)
update 表a.col = 1;
else (b.maintaindate < datatime.now)
update 表a.col = 0;
else(表b.maintaindate == null)
date = b.singdate + time(某种方法处理,让这两个能够相加)
for(记录中循环)
date = 最晚时间
重复比较和更新。现在,清除了吧。
(你用的是什么数据库啊,我用SQL Server的存储过程哈,你上面是什么数据库的语法?)If Exists(select * from b.maintaindate > GetDate() where clientid = 188 )
update 表a.col = 1 where id=188
ElseIf Exists(select * from b.maintaindate is not Null )
update 表a.col = 0 where id=188
Else
Begin
date = b.singdate + time(某种方法处理,让这两个能够相加) --某种方法处理,你自
--己想了哈
-- 这里要好好处理了,你要得到 date的值,可能这里比较麻烦吧
If date > GetDate()
update 表a.col = 1 where id=188
Else
update 表a.col = 0 where id=188
End