首先我想知道这个语句:
“select top n * from TABLE_NAME where id not in (select top n id from TABLE_NAME )” 是不是从第(n+1)个记录开始选择,而到第2n个记录结束,总共选则n个?(还是说从第n个开始到第2n个结束,那样的话岂不是选择了n+1个记录?) 我想问问如何将下面这个my sql的limit语句转换成sql server top的语句:
(1).sqlStr="Select * From a"; /*a是一个table名*/
(2).sqlStr=sqlStr+"and ID='"+Id+"limit"+m+","+n;
如果仅仅将后面的"limit"+m+","+n 改为sql server语句应该是:select top n ID from a where ID not in (Select top m ID from a);
但(2)是个sqlStr语句的叠加,还有个and连接,我就不知道该如何结合(1)将(2)整个语句该成sql server top的语句.
请大家帮帮忙了,谢谢!
“select top n * from TABLE_NAME where id not in (select top n id from TABLE_NAME )” 是不是从第(n+1)个记录开始选择,而到第2n个记录结束,总共选则n个?(还是说从第n个开始到第2n个结束,那样的话岂不是选择了n+1个记录?) 我想问问如何将下面这个my sql的limit语句转换成sql server top的语句:
(1).sqlStr="Select * From a"; /*a是一个table名*/
(2).sqlStr=sqlStr+"and ID='"+Id+"limit"+m+","+n;
如果仅仅将后面的"limit"+m+","+n 改为sql server语句应该是:select top n ID from a where ID not in (Select top m ID from a);
但(2)是个sqlStr语句的叠加,还有个and连接,我就不知道该如何结合(1)将(2)整个语句该成sql server top的语句.
请大家帮帮忙了,谢谢!
select top 4 from (select top 10 id from tt order by id)
select top 4 from (select top 10 id from tt order by id)
这样的语句,最好贴记录出来看看
“select top n * from TABLE_NAME where id not in (select top n id from TABLE_NAME )” 是不是从第(n+1)个记录开始选择,而到第2n个记录结束,总共选则n个?(还是说从第n个开始到第2n个结束,那样的话岂不是选择了n+1个记录?)假设有10条记录,第二个N为3,则返回从4-10的记录我想问问如何将下面这个my sql的limit语句转换成sql server top的语句:
(1).sqlStr="Select * From a"; /*a是一个table名*/
(2).sqlStr=sqlStr+"and ID='"+Id+"limit"+m+","+n;
如果仅仅将后面的"limit"+m+","+n 改为sql server语句应该是:select top n ID from a where ID not in (Select top m ID from a);
但(2)是个sqlStr语句的叠加,还有个and连接,我就不知道该如何结合(1)将(2)整个语句该成sql server top的语句.
请大家帮帮忙了,谢谢! 类似
select top 4 from (select top 10 id from tt order by id)
这样就行了。
select * from tablename where 1 limit n-1,n