How to get the oder pages

  • I use a

    SELECT TOP 50 xy FROM MyTable.

    Could someone suggest me the better way to get de 50 to 100, 100 to 150 and so on... pages.

     

    Thanks

  • Need a where clause and some ordering mechanism.

    Like

    select top 50 xy from MyTable order by MyID

    then for the next 50, send in the last ID you got and query

    select top 50 xy from MyTable order by MyID where MyID > @lastid

  • So !

    this need to get the lastID as :

    declare LyID int,

    select top 50 xy, @lastID=MyID from MyTable order by MyID

    and then

    select top 50 xy from MyTable order by MyID where MyID > @lastID

    Am I right ?

  • But I don't find How to memorize the lastID ???? In my first select request I get the ID, but which is the last ???

  • select top 50 xy, @lastID=max(MyID) from MyTable order by MyID

    and then

    select top 50 xy from MyTable order by MyID where MyID > @lastID

  • Sorry, you can't combine the select like that.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply