首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

这句SQL该如何写才对

2012-03-07 
这句SQL该怎么写才对selecta.id,a.xxx,b.yyy,b.addtimefroma,bwhereb.fida.idandb.fidin(selecta.idfroma

这句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

热点排行