Sql server 选择第8行后的前3行
我有一个表:id、组、状态、主题 我需要group=2和status=2的行,但我想跳过按id排序的前8个结果。这是我尝试的,但它不会跳过前8行:Sql server 选择第8行后的前3行,sql-server,sql-server-2008,Sql Server,Sql Server 2008,我有一个表:id、组、状态、主题 我需要group=2和status=2的行,但我想跳过按id排序的前8个结果。这是我尝试的,但它不会跳过前8行: SELECT TOP 3 [id], LEFT ([subject],30) AS Title FROM [Katavot] WHERE (([Status] = @Status) AND ([Group] = @Group)) ORDER BY [id] DESC 看起来很像 看起来非常类似。基于 基于 MySQL: MSSQL:
SELECT TOP 3 [id], LEFT ([subject],30) AS Title
FROM [Katavot]
WHERE (([Status] = @Status) AND ([Group] = @Group))
ORDER BY [id] DESC
看起来很像
看起来非常类似。基于
基于
MySQL:
MSSQL:
select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>
MySQL:
MSSQL:
select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>
LIMIT x, y
select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>