Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using an sql statement select next 4 items

Is there a way to select the next 4 items in a sql query. I have a sql query populating an asp repeater and its using a "select top 4 from ....." sql query. I want a button to select the next 4 from the database. Is this possible? Thanks all.

like image 238
Wesley Skeen Avatar asked Sep 28 '26 04:09

Wesley Skeen


1 Answers

SELECT  ID, Foo, Bar
FROM     (SELECT  ROW_NUMBER() OVER (ORDER BY ID ASC) AS Row,
          ID, Foo, Bar
FROM    SomeTable) tmp
WHERE   Row >= @RowRangeStart AND Row <= @RowRangeEnd

retrieve specific range of rows in a SQL Server table

like image 104
James Johnson Avatar answered Sep 30 '26 08:09

James Johnson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!