Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8831465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:18:52+00:00 2026-06-14T08:18:52+00:00

I am trying to implement pagination to a page on my website that returns

  • 0

I am trying to implement pagination to a page on my website that returns results from a database table.

Currently, it returns all rows in a random order. However, as my database is growing, I want to paginate these results instead of displaying them all on one page. However, I don’t want to return all results just to display 20 records for instance. Depending on the page, I want take just the 20 records from the database that are relevant.

I’m following this tutorial: Tutorial

However, the I cannot use the query with the OFFSET clause, because the hosting uses SQL SERVER 2008. (It is introduced in 2012 i believe).

I tried following the answer to this Question, but I want the results in a random order, and I cannot do an ORDER BY on a derived table… so I’m a bit stuck for ideas!

Any help? Thanks!

This is what I currently have:

    SELECT Title, Filename, PhotoURL, Orientation, FolderName, SetURL, RowNum
      FROM (
            SELECT  p.Title, p.Filename, p.URL AS PhotoURL, p.Orientation, s.FolderName, s.URL AS SetURL, ROW_NUMBER() OVER (ORDER BY p.PhotoID) AS RowNum
          FROM  Photos p
                LEFT OUTER JOIN SetPhotos sp
                    ON sp.PhotoID = p.PhotoID
                LEFT OUTER JOIN [Sets] s
                    ON s.SetID = sp.SetID
         WHERE  p.Hide = 0
      ORDER BY  NEWID()
        ) AS PaginatedPhotos
 WHERE  PaginatedPhotos.RowNum BETWEEN 0 AND 10
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T08:18:53+00:00Added an answer on June 14, 2026 at 8:18 am
    1. Add integer column ‘order’ to your table
    2. Write a code that fills this column in all rows with unique random numbers
    3. Run this code from time to time to shuffle your rows
    4. Make pagination as usual while sorting by ‘order’

    Keep in mind that the same rows can appear on different pages if you shuffle rows in the middle of someone paginating.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi people thanks for the help. Im trying to implement a simple pagination that
I am trying to implement pagination in my search results with Yii. I have
Im trying to implement pagination using multiple searching criteria. Supposed I Have student table.
I am trying to implement Pagination in JSF using Tomahawk. When the page is
I am trying to implement the previous page functionality for pagination, and I thought
I am currently trying implement a QThread that contains a socket connection. The socket
I am new to both MVC and Stackoverflow I am trying to implement pagination
i am trying to implement pagination. A set of 9 products are displayed at
I'm trying implement server code of Server-Sent Events in a generic way that any
I'm trying to implement pagination in my Rails 3 app with Kaminari but I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.