Suche…


Einige Zeilen aus dem Ergebnis überspringen

ISO / ANSI SQL:

SELECT Id, Col1
FROM TableName
ORDER BY Id
OFFSET 20 ROWS

MySQL:

SELECT * FROM TableName LIMIT 20, 42424242424242;
-- skips 20 for take use very large number that is more than rows in table

Orakel:

SELECT Id,
   Col1
FROM (SELECT Id,
           Col1,
           row_number() over (order by Id) RowNumber
      FROM TableName)
WHERE RowNumber > 20

PostgreSQL:

SELECT * FROM TableName OFFSET 20;

SQLite:

SELECT * FROM TableName LIMIT -1 OFFSET 20;

Begrenzung der Anzahl der Ergebnisse

ISO / ANSI SQL:

SELECT * FROM TableName FETCH FIRST 20 ROWS ONLY;

MySQL; PostgreSQL; SQLite:

SELECT * FROM TableName LIMIT 20; 

Orakel:

SELECT Id,
   Col1
FROM (SELECT Id,
           Col1,
           row_number() over (order by Id) RowNumber
      FROM TableName)
WHERE RowNumber <= 20

SQL Server:

SELECT TOP 20 * 
FROM dbo.[Sale]

Überspringen und einige Ergebnisse aufnehmen (Paginierung)

ISO / ANSI SQL:

SELECT Id, Col1
FROM TableName
ORDER BY Id
OFFSET 20 ROWS FETCH NEXT 20 ROWS ONLY;

MySQL:

SELECT * FROM TableName LIMIT 20, 20; -- offset, limit

Orakel; SQL Server:

SELECT Id,
   Col1
 FROM (SELECT Id,
           Col1,
           row_number() over (order by Id) RowNumber
      FROM TableName)
WHERE RowNumber BETWEEN 21 AND 40

PostgreSQL; SQLite:

SELECT * FROM TableName LIMIT 20 OFFSET 20;


Modified text is an extract of the original Stack Overflow Documentation
Lizenziert unter CC BY-SA 3.0
Nicht angeschlossen an Stack Overflow