日期:2014-05-18  浏览次数:20564 次

这句SQL该怎么写才对
select   a.id,a.xxx,b.yyy,b.addtime  
from   a,b  
where   b.fid=a.id
and   b.fid   in   (select   a.id   from   a,b   where   b.fid=a.id   and   datediff(day,b.nexttime,getdate())=0   order   by   b.addtime   desc)   order   by   b.addtime   desc

出错地方在
b.fid   in   (select   a.id   from   a,b   where   b.fid=a.id   and   datediff(day,b.nexttime,getdate())=0   order   by   b.addtime   desc)

这一句该如何写

------解决方案--------------------
select a.id,a.xxx,b.yyy,b.addtime
from a,b
where b.fid=a.id
and b.fid in (select a.id from a,b where b.fid=a.id and datediff(day,b.nexttime,getdate())=0)
order by b.addtime desc