Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Select (SQL)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Method with positioning ==== # Select only <code>{rows}</code> rows starting from the next row to display (<code>{begin_base_0 + 1}</code>) # Read and send to display all the rows read from the database {|class="wikitable" |- ! SQL ! Dialect |- | <syntaxhighlight lang="postgres">Select * from {table} order by {unique_key} OFFSET {begin_base_0} ROWS FETCH NEXT {rows} ROWS ONLY</syntaxhighlight> | SQL ANSI 2008<br>PostgreSQL<br>SQL Server 2012<br>Derby<br>Oracle 12c<br>DB2 12<br>Mimer SQL |- | <syntaxhighlight lang="postgres">Select * from {table} order by {unique_key} LIMIT {rows} OFFSET {begin_base_0}</syntaxhighlight> | MySQL<br>MariaDB<br>PostgreSQL<br>SQLite |- | <syntaxhighlight lang="mysql">Select * from {table} order by {unique_key} LIMIT {begin_base_0}, {rows}</syntaxhighlight> | MySQL<br>MariaDB<br>SQLite |- | <syntaxhighlight lang="mysql">Select * from {table} order by {unique_key} ROWS LIMIT {rows} OFFSET {begin_base_0}</syntaxhighlight> | Sybase, ASE 16 SP2 |- | <syntaxhighlight lang="tsql">Select TOP {begin_base_0 + rows} *, _offset=identity(10) into #temp from {table} ORDER BY {unique_key} select * from #temp where _offset > {begin_base_0} DROP TABLE #temp</syntaxhighlight> | Sybase 12.5.3: |- | <syntaxhighlight lang="tsql">SET ROWCOUNT {begin_base_0 + rows} select *, _offset=identity(10) into #temp from {table} ORDER BY {unique_key} select * from #temp where _offset > {begin_base_0} DROP TABLE #temp SET ROWCOUNT 0</syntaxhighlight> | Sybase 12.5.2: |- | <syntaxhighlight lang="tsql">select TOP {rows} * from ( select *, ROW_NUMBER() over (order by {unique_key}) as _offset from {table} ) xx where _offset > {begin_base_0}</syntaxhighlight> <br> | SQL Server 2005 |- | <syntaxhighlight lang="tsql">SET ROWCOUNT {begin_base_0 + rows} select *, _offset=identity(int,1,1) into #temp from {table} ORDER BY {unique-key} select * from #temp where _offset > {begin_base_0} DROP TABLE #temp SET ROWCOUNT 0</syntaxhighlight> | SQL Server 2000 |- | <syntaxhighlight lang="sql">SELECT * FROM ( SELECT rownum-1 as _offset, a.* FROM( SELECT * FROM {table} ORDER BY {unique_key} ) a WHERE rownum <= {begin_base_0 + cant_regs} ) WHERE _offset >= {begin_base_0}</syntaxhighlight> | Oracle 11 |} <br>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)