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

  • Home
  • SEARCH
  • 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 7658515
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:12:43+00:00 2026-05-31T13:12:43+00:00

Let’s say I have 10 tables, each tableN has an ID and a ValueN.

  • 0

Let’s say I have 10 tables, each tableN has an ID and a ValueN.
I want to combine all of them into one table which has the following content:

ID Value1 Value2 Value3 ...

The IDs are unique but each table can have any number of records, so a result row can be:

001 3.1 Null 4.6 ...

I know how to do this simple query when there are only 2 tables. But don’t know the best way to compare the ID values from 10 tables.

  • 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-31T13:12:44+00:00Added an answer on May 31, 2026 at 1:12 pm

    Say you have 3 tables (or any number of tables)

    Table1:          Table2:           Table3
    ID  Value1       ID   Value2       ID   Value3
    1   A            1    AAA          1    111
    2   B            2    BBB          2    222
    3   C            5    EEE          3    333
                                       4    444
                                       5    555
    

    You can use a query like this to make sure that you get all possible data from all tables:

    SELECT U.ID,
           Table1.Value1,
           Table2.Value2,
           Table3.Value3
    FROM   (((SELECT ID FROM Table1
              UNION
              SELECT ID FROM Table2
              UNION
              SELECT ID FROM Table3) AS U
             LEFT JOIN Table1 ON U.ID=Table1.ID)
            LEFT JOIN Table2 ON U.ID=Table2.ID)
           LEFT JOIN Table3 ON U.ID=Table3.ID; 
    

    The result of which is:

    ID    Value1    Value2     Value3
    1     A         AAA        111
    2     B         BBB        222
    3     C                    333
    4                          444
    5               EEE        555    
    

    Basically, it’s just a succession of LEFT JOIN on each table, all joined by the union of all possible IDs accross all tables:

    SELECT ID FROM Table1
    UNION
    SELECT ID FROM Table2
    UNION
    SELECT ID FROM Table3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have one class User, and it has a property of type
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have thousands of users and I want to make the passwords
Let's say I have four samples: id=1, 2, 3, and 4, with one or
Let's say you have a class library project that has any number of supplemental
Let's say I have many items with click event (all have same element name
Let's say you have an array like this: array ( ['one'] => array (
Let's say that I have a rails plugin called wipy on GitHub. It has
Let's say I have a large amount of files, say 20GB worth, all encrypted
Let's say I have two objects, Master and Slave . Slave has a method

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.