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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:05:14+00:00 2026-06-09T20:05:14+00:00

I am using mysql and I have three tables T1, T2, T3 they contain

  • 0

I am using mysql and I have three tables T1, T2, T3
they contain data as follows:

+-------+
| t1.id |
+-------+
| 1    |
| 2    |
| 3    |
| 4    |
| 5    |
+------+

+-------+
| t2.id |
+-------+
| 1    |
| 2    |
| 3    |
| 4    |
+-------+

+-------+
| t3.id |
+-------+
| 1    |
| 2    |
| 3    |
+-------+

    I want to be able to select data as follows:

id      t1.id   t2.id   t3.id
1       1       1       1
2       2       2       2
3       3       3       3
4       4       4       null
5       5       null    null

How can I do this?

  • 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-09T20:05:16+00:00Added an answer on June 9, 2026 at 8:05 pm
    SELECT t1.id, t2.id, t3.id
    FROM t1 
    LEFT JOIN t2 ON t1.id=t2.id
    LEFT JOIN t3 ON t1.id=t3.id
    

    works, if t1 is guaranteed to have a strict superset of all ids.

    If not, you would need a helper table:

    SELECT th.id,t1.id, t2.id, t3.id
    FROM (
      SELECT id FROM t1
      UNION DISTINCT 
      SELECT id FROM t2
      UNION DISTINCT 
      SELECT id FROM t3
    ) AS th
    LEFT JOIN t1 ON th.id=t1.id
    LEFT JOIN t2 ON th.id=t2.id
    LEFT JOIN t3 ON th.id=t3.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using MySQL I have three tables: accounts { account_id, username } account_ips {
Using MySQL, I have three tables: projects : ID name 1 birthday party 2
I have some historical data tables in my Mysql database. I want to repeat
using php and mysql I have two tables, a users table and a profiles
I have created a MySQL database using MySQL Workbench. It has about 20 tables.
I'm using MySQL. I have 3 tables I'm trying to connect in a query
I have several MySQL tables with the same structure. They all have a date
I have three tables in MySQL that are related, yet not technically linked to
I am collecting data and store this data in a MySQL database using Java.
I am using mysql and have a table (Log_Table) storing user login dates, a

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.