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

语法异常,帮看看。

2012-02-09 
语法错误,帮看看。。。SQL codeACCESS的语法错误。 在查询表达式 中。 select top 20 * from bbs_content as

语法错误,帮看看。。。

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

热点排行