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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:19:49+00:00 2026-06-13T12:19:49+00:00

I was trying to think of a logic to implement this mysql query but

  • 0

I was trying to think of a logic to implement this mysql query but i couldn’t think of anything or find anything on the internet. My task is to Join two or more tables and return it’s matching fields. BUT if there are three tables matching rows on two tables has to be displays also. Say I have these 3 tables,

Table1-
num |info
----------
1   |aaaaa  
2   |bbbb
3   |ccc
4   |dddd
4   |dddd
5   |eeee

Table2-
num |info
----------
2   |bbbb
3   |ccc
4   |dddd
5   |eeee

Table3-
num |info
----------
1   |aaaaa
2   |bbbb
6   |ffff
7   |gggg

I want to join these three tables and get a result as follows,

Result-
num |info   num |info   num |info
----------- ----------- ----------
1   |aaaaa  NULL|NULL   1   |aaaaa
2   |bbbb   2   |bbbb   2   |bbbb
3   |ccc    3   |ccc    NULL|NULL
4   |dddd   4   |dddd   NULL|NULL
4   |dddd   4   |dddd   NULL|NULL
5   |eeee   5   |eeee   NULL|NULL

I have this query which only shows that is on all three tables.

   SELECT a . * , b. * , c . *
   FROM tbl_1 a
   JOIN tbl_2 b ON a.num = b.num
   JOIN tbl_3 c ON a.num = c.num
   ORDER BY a.num, b.num

BUT what i want, is to display even if the value appears in two tables.

Thank you very much. if this was addressed before it would be great help in pointing me in the right direction 🙂 thanks again

TABLE STRUCTURE UPDATE

Table1-
num |info
----------
1   |aaaaa  
2   |bbbb
3   |ccc
3   |ccc
4   |dddd

Table2-
num |info
----------
1   |aaaaa
3   |ccc
4   |dddd
5   |eeee
6   |ffff

Table3-
num |info
----------
1   |aaaaa
6   |ffff
2   |bbbb

in such a senario the record 6 |ffff doesnt get displayd,

DESIRED OUTPUT UPDATE

the result i want to obtain is,

Result-
num |info   num |info   num |info
----------- ----------- ----------
1   |aaaaa  1   |aaaaa  1   |aaaaa
2   |bbbb   NULL|NULL   2   |bbbb
3   |ccc    3   |ccc    NULL|NULL
3   |ccc    3   |ccc    NULL|NULL
4   |dddd   4   |dddd   NULL|NULL
NULL|NULL   6   |ffff   6   |ffff
  • 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-13T12:19:50+00:00Added an answer on June 13, 2026 at 12:19 pm

    This question was resolved by @Andreas Wederbrand,

    Full join for 3 tables

    Implementing a full join was the solution for my query.

    Hope it helps for anyone who comes across this issue 🙂

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

Sidebar

Related Questions

I could solve this using loops, but I am trying think in vectors so
I'm trying to think of the correct design for a web service. Essentially, this
I am trying to think data in terms of sets but have some questions
So I am trying to think of a way to facilitate two things. It
This might be quite simple but I have spent hours in Google but couldn't
First, I'll explain the situation and the logic that I'm trying to implement: I
I am trying to understand the concept behind logic-less temlpates, but I'm finding myself
I am trying to implement logic captcha in my app. I have scaffolded simple
I see several questions relating somewhat to this, but I still can't find the
Hi! I'm trying to implement an alpha-beta search, but i first want to understand

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.