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 4020498
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:14:09+00:00 2026-05-20T10:14:09+00:00

I somehow need a way for the following: User is located at some blog

  • 0

I somehow need a way for the following:

User is located at some blog page Now I want to give him the ability to move either:

To the next more popular page OR to the next less popular page. Means, something like this:

[PAGE 5] | [PAGE 3 (User is here)] | [PAGE 2]

(Where Page 1 = most popular, Page 3 = least popular). My MySQL Table looks like this:

[ID] [VIEWS]
[1] [1000]
[2] [2560]
[3] [3200]
[4] [200]
[5] [4000]

My problem is the specific query. The only given variable is the ID: 2 in this case. Maybe you can help me out. Just tell me if you need further informations.
(I only need the two neighbours. Page 4 etc. would not be needed.)

Edit: @Trevor No, sorry I cant. I changed the example so its more clearly.

  • 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-05-20T10:14:09+00:00Added an answer on May 20, 2026 at 10:14 am

    NOTE: As worked out in the various comments, @mellamokb’s answer is better than mine. I would delete this answer but am unable to since it was accepted.

    /* Next Page */
    SELECT ID
        FROM YourTable
        WHERE VIEWS <= (SELECT VIEWS FROM YourTable WHERE ID = $CurrentPageId)
            AND ID < $CurrentPageId
        ORDER BY VIEWS DESC, ID DESC LIMIT 1
    
    /* Previous Page */
    SELECT ID
        FROM YourTable
        WHERE VIEWS >= (SELECT VIEWS FROM YourTable WHERE ID = $CurrentPageId)
            AND ID > $CurrentPageId
        ORDER BY VIEWS, ID LIMIT 1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem and I need to know if there´s a way
I have a large dataframe. For some purposes I need to do the following:
Currently trying to find a way to do the following inside some form of
I have the following JSF 2.1 page <h:selectOneRadio value=#{userBean.newUser}> <f:selectItem itemValue=0 itemLabel=new User />
I'm trying to hack a 3rd party JavaScript pop-up and I need to somehow
I need to Open a process (easy) and then somehow paste data from my
PriorityBlockingQueue is unbounded, but I need to bound it somehow. What is the best
I am an IT guy, and what I need to do is to somehow
I am having some trouble with the following queries originally done for some Access
Please consider following example: The source image consists of 6 areas that need to

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.