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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:04:10+00:00 2026-06-06T01:04:10+00:00

I have three tables of data: table: cars [10,000 rows] table: planes [2,000 rows]

  • 0

I have three tables of data:

table: cars    [10,000 rows]
table: planes  [2,000 rows]
table: trains  [50 rows]

I’d like to be able to show users a page of data taken from the three tables like:

car
plane
train
car
plane
train
...

The point being that they can keep paging, seeing one of each type, until each table is exhausted. For example, at some point, each page would only contain cars as the plane and train tables will be exhausted way before the cars table is.

Is there a query I can run to grab one row from each table, until a limit is reached? Something like:

SELECT * FROM cars, planes, trains ORDER BY (natural row ordering?) LIMIT 20;

The only way I can think to get this done is to make one master table, and assign a dummy integer to each row as I insert them:

  id |  type  | description | dummy_integer
--------------------------------------------
 ...    car     ...             0
 ...    plane   ...             1
 ...    train   ...             2
 ...    car     ...             3
 ...    plane   ...             4
 ...    train   ...             5
 ...    ...     ...             ...
 ...    car     ...             8000
 ...    car     ...             8001
 ...    car     ...             8002
 ...    ...     ...             ...

Then I can do:

SELECT * FROM master_table ORDER BY dummy_integer ASC LIMIT 20;

and paging is done by using the last-seen dummy_integer:

SELECT * FROM master_table WHERE dummy_integer > 20 
    ORDER BY dummy_integer ASC LIMIT 20;

Then the problem becomes that when I get some new train records for example, I can append them to the end of master_table, but their dummy integer values would put them all the way at the end. Therefore if a user starts looking at my pages from the start, they won’t see that newer train data until they page through the cars desert, instead of nicely interleaved with the cars/planes up towards the front.

Is there any good way of doing this besides the above (not so great) way?

Thanks

  • 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-06T01:04:11+00:00Added an answer on June 6, 2026 at 1:04 am

    Aren’t the commas on your query actually performing a join?

    I’d use an UNION and ORDER BY to achieve that:

    SELECT id, type, description FROM cars
    UNION
    SELECT id, type, description FROM planes
    UNION
    SELECT id, type, description FROM trains
    ORDER BY id, type
    

    (working example)

    For pagination, you can use LIMIT with OFFSET (see docs).

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

Sidebar

Related Questions

I have three tables, table one (tableA) containing users data like name and email,
So... assuming i have a database with three tables: Table clients Table data and
I have three tables: 'users', 'products', and 'product_types'. The 'users' table stores all usual
I have three tables, 1-Users, 2-Softwares, 3-UserSoftwares. if suppose, Users table having 6 user
I have three tables, with two data relations connecting them (Table 1 -> Table
I have three tables that contain data relating to a Job. One table is
Ok, here's the condensed form. I have three main tables to draw data from:
I have a MySQL query that: gets data from three tables linked by unique
I have a Microsoft SQL Server 2008 query that returns data from three tables
I have a table in my data base that has three columns: Screen, Icon,

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.