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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:26:57+00:00 2026-05-31T11:26:57+00:00

I am using the below query to paginate posts on my site: select *

  • 0

I am using the below query to paginate posts on my site:

select * from songs t1 join (
select to_days(date) day from songs 
group by day 
order by day desc 
limit $start_row, $items_per_page
) t2
on to_days(t1.date) = t2.day

Depending on my $start_row and $items_per_page this will return all the posts for say, the last 7 days. Regardless of if there was more than 1 post per day or a day is empty and skipped.

For example:

sample results

Above the query has correctly returned all the posts from the latest 7 days. Today. Yesterday. The day before that and so on…

However if you look at the table id 12## values on the far left, and time stamp day values 73#### on the far right. You will see they are grouped backwards.

How do I switch this query around so that it returns the same results in the same grouping but in a reverse order?

For example:

Oh My! – Run This Town(TMS remix)
Lost Mapaches-Back To Basics (La Royale Remix)

Dimitri from Paris & DJ Rocca-I Need A Reason For LIving (Radio Mix)
Chromeo – Hot Mess (23 Dubstep Remix)

and so on… I tried removing the desc value but that just returns the grouping from the oldest entries in the table.

  • 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-31T11:26:58+00:00Added an answer on May 31, 2026 at 11:26 am

    I would order your data on the outside of the subquery (note the last line), please adjust last line for asc / desc or if you want to order by.

    select * from songs t1 join (
    select to_days(date) day from songs 
    group by day 
    order by day desc 
    limit $start_row, $items_per_page
    ) t2
    on to_days(t1.date) = t2.day
    order by id desc
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I m using below query from c# to compare current date with date stored
I am using below CAML query but when I run,it returns all data from
I'm using the below query to return results from a table using Full-Text-Search. In
I am using this below given query: SELECT o.orders_id, o.customers_name, o.customers_id, o.payment_method, o.google_order_id, o.date_purchased,
Below query is resulting NO rows lstResults.RowSource = select EmpId from tblTesting where Empid
I am trying to fetch records from the table using the below sql query.
Using SQL Sever 2005 From the below Query Am getting total worked time means
I'm using the query below to get posts based on the start and end
im joining and retrieving values from two tables using the below query. It displays
I have created a line chart using below code. select * from ( select

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.