Jump to content

Simulating a FULL OUTER JOIN -- How?


mrherman

Recommended Posts

Hi,

 

I discovered to my chagrin that MySQL does not do FULL OUTER JOINs.

 

At any rate, after much researching, I have ended up with the code below, in which each of the queries works separately, but when I try to join them with the UNION clause, I receive an error saying that "can't reopen temp2".

 

These are all are temporary tables -- Does that make a difference?

 

SELECT temp1.last_name
   FROM temp1 LEFT OUTER JOIN temp2
        ON temp1.student_id = temp2.student_id  
UNION
SELECT temp2.last_name
    FROM temp2 LEFT OUTER JOIN temp1
         ON temp2.student_id = temp1.student_id ;

 

I've tried parentheses, etc., but nothing has worked yet.  Thanks for any advice!

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.