读书人

语法异常帮看看。

发布时间: 2012-02-09 18:22:27 作者: rapoo

语法错误,帮看看。。。

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

读书人网 >其他数据库

热点推荐