Jump to content

Full Outer Join


Basti86

Recommended Posts

Good day,

 

I am expiriencing a small problem with a mySQL statement. The problem is nothing new because I think it is about the missing FULL OUTER JOIN issue.

 

I have read many workarounds but for some reason they just dont seem to work. I have a novice level knowhow of SQL but am eager to solve this problem( with your help ;> ).

 

I have two tables.

 

 

table A

| id | structID | some more colums..
-----------------------------------
| 1  | 1        |
| 1  | 2        |
| 2  | 2        |

 

table B

| structID | name | other colums
-----------------------------------
|    1     | AB   |
|    2     | BC   |

 

What I need to do is perform a SELECT on both tables and the result should be something like this:

 

WHERE id = 2

 

|structID |  id | name
----------------------------------
| 1       | null | AB
| 2       |  2   | BC

To keep it simple: I need a list of all structIDs and if they occured in the ID I sepcified.

 

I tried it with an INNER LEFT JOIN but never received a NULL in any result..

 

Am I way off track, do I need to reorganize these tables or how can I accomplish what I want to do?

 

-Greetings...

 

Link to comment
Share on other sites

Arr, where is the edit button?

 

My SQLStatement til now:

 

SELECT *
FROM tableB LEFT JOIN tableA ON tableB.structID = tableA.structID
UNION ALL
SELECT *
FROM tableB RIGHT JOIN tableA ON tableB.structID = tableA.structID
WHERE tableA.id IS NULL

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.