这个语句应该怎么改

[复制链接]
查看11 | 回复3 | 2008-10-25 14:40:36 | 显示全部楼层 |阅读模式
select * from tbl_topic where boardId=4 and topicid in ( selecttopicId from tbl_reply order by modifytime desc)
错误提示:消息 1033,级别 15,状态 1,第 1 行
除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询和公用表表达式中无效。

回复

使用道具 举报

千问 | 2008-10-25 14:40:36 | 显示全部楼层
大牛:你这个语句是个嵌套语句,其中有一个子查询(就是你括号里内容),而在子查询中用ORDERBY是无效的,你想想子查询返回的也是一个集合,排不排序对你的in 来说也没有什么太大的影响。可以把order by 去掉。select * from tbl_topic where boardId=4 and topicid in ( select topicId from tbl_reply )...
回复

使用道具 举报

千问 | 2008-10-25 14:40:36 | 显示全部楼层
select * from tbl_topic where boardId=4 and topicid in ( select topicId from tbl_reply )...
回复

使用道具 举报

千问 | 2008-10-25 14:40:36 | 显示全部楼层
select * from tbl_topic where boardId=4 and topicid in ( select topicId from tbl_reply ) order by modifytime desc或select * from tbl_topic where boardId=4 and topicid in ( s...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行