当前位置: 代码迷 >> 其他数据库 >> 语法异常,帮看看。
  详细解决方案

语法异常,帮看看。

热度:9446   发布时间:2013-02-26 00:00:00.0
语法错误,帮看看。。。
SQL code
ACCESS的语法错误。 在查询表达式 '' 中。 select top 20 * from bbs_content as a inner join (select replyTitleId from bbs_reply where replyUserName='zzxap')b on a.id=b.replyTitleId and a.[id]<=( select min([id]) from ( select TOP 1 c.id from bbs_content c inner join (select replyTitleId from bbs_reply where replyUserName='zzxap')d on c.id=d.replyTitleId ORDER BY c.id desc ) as e ) ORDER BY a.[id] desc


------解决方案--------------------------------------------------------
select top 20 * from bbs_content as a inner join (select replyTitleId from bbs_reply where replyUserName='zzxap') b on (a.id=b.replyTitleId )
where a.[id]<=(select min([id]) from ( select TOP 1 c.id from bbs_content c inner join (select replyTitleId from bbs_reply where replyUserName='zzxap') d on c.id=d.replyTitleId ORDER BY c.id desc ) as e)
 ORDER BY a.[id] desc



------解决方案--------------------------------------------------------
这个子句貌似没必要

select min([id]) from ( select TOP 1 c.id from bbs_content c inner join
 (select replyTitleId from bbs_reply where replyUserName='zzxap')d 
on c.id=d.replyTitleId ORDER BY c.id desc ) as e

只用这个应该就可以了
select TOP 1 c.id from bbs_content c inner join
 (select replyTitleId from bbs_reply where replyUserName='zzxap')d 
on c.id=d.replyTitleId ORDER BY c.id desc

或者
select Min(c.id) from bbs_content c inner join
 (select replyTitleId from bbs_reply where replyUserName='zzxap')d 
on c.id=d.replyTitleId
------解决方案--------------------------------------------------------
select top 20 * 
from bbs_content as a inner join 
(select replyTitleId from bbs_reply where replyUserName='zzxap') b
  on a.id=b.replyTitleId 
where a.[id]<=
( select min([id]) from 
( select TOP 1 c.id 
from bbs_content c inner join (select replyTitleId from bbs_reply where replyUserName='zzxap') d 
on c.id=d.replyTitleId 
ORDER BY c.id desc 
) as e 

ORDER BY a.[id] desc
  相关解决方案