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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:17:32+00:00 2026-06-13T08:17:32+00:00

I have this query to simulate full join of three tables in mysql, SELECT

  • 0

I have this query to simulate full join of three tables in mysql,

SELECT a. * , b. * , c. *
FROM tbl_1 a
LEFT OUTER JOIN tbl_2 b ON a.num = b.num
LEFT OUTER JOIN tbl_3 c ON a.num = c.num
UNION
SELECT a. * , b. * , c. *
FROM tbl_1 a
RIGHT OUTER JOIN tbl_2 b ON a.num = b.num
RIGHT OUTER JOIN tbl_3 c ON a.num = c.num

But the result it generates is not what i am expecting, the tables that i am going to join are as follows,

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

And the result I am expecting is,

Required result 1-
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   5   |eeee   NULL|NULL
NULL|NULL   6   |ffff   6   |ffff

OR

Required result 2-
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

But what i get is

Result i get-
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   NULL|NULL   6   |ffff
NULL|NULL   NULL|NULL   2   |bbbb

May i know what is wrong over here, i’ve been stuck with this for 2 days and couldn’t resolve..may i know the query to obtain the result i want?

Thank you very much 🙂

  • 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-13T08:17:33+00:00Added an answer on June 13, 2026 at 8:17 am

    This works as shown in John Woo’s comment with sql fiddle. (the original answer contained an error but it should now work)

    SELECT a. * , b. * , c. *
    FROM tbl_1 a
    LEFT OUTER JOIN tbl_2 b USING (num)
    LEFT OUTER JOIN tbl_3 c USING (num)
    UNION
    SELECT a. * , b. * , c. *
    FROM tbl_2 b
    LEFT OUTER JOIN tbl_1 a USING (num)
    LEFT OUTER JOIN tbl_3 c USING (num)
    UNION
    SELECT a. * , b. * , c. *
    FROM tbl_3 c
    LEFT OUTER JOIN tbl_1 a USING (num)
    LEFT OUTER JOIN tbl_2 b USING (num)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this query in Mysql SELECT z.virtuemart_product_id,z.product_name,d.product_price FROM x5lui_virtuemart_products x inner join x5lui_virtuemart_products_en_gb
I have this query and result in my database: mysql> SELECT id FROM jos_content
I have this query: SELECT p.id, r.status, r.title FROM page AS p INNER JOIN
I have this query... SELECT Distinct([TargetAttributeID]) FROM (SELECT distinct att1.intAttributeID as [TargetAttributeID] FROM AST_tblAttributes
I have this query: SELECT * From checkfinale where AssociateID = 51 AND `CompletedDate`
I have this query: SELECT DISTINCT phone, department FROM `users` WHERE ((SUBSTRING(phone,1,3) = '399')
I have this query select CONVERT(varchar(5), tdate ,108) AS [Time] from table which gives
I have this query $query = mysql_query (SELECT type, count(*), date FROM tracking WHERE
I have this query which involves a table from another server: select count(serialno), max(convert(varchar(10),Crtd_DateTime,101))
I have this query: select id from mytable where contains(all_text,'('||?||' within name)*2, ('||?||' within

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.