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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:12:58+00:00 2026-06-18T08:12:58+00:00

I am trying to do a FULL OUTER JOIN in MySQL and as we

  • 0

I am trying to do a FULL OUTER JOIN in MySQL and as we all know that is not possible with their syntax. So, like any normal tinkerer I am using:

(T1 LEFT OUTER JOIN T2) UNION (T1 RIGHT OUTER JOIN T2)

Now here’s the catch! Each of the individual joins (left and right) work like a charm, but together they give an error (1064: syntax error) and I am prompted to check my MySQL Server manual for correct syntax.

Here’s the code:

(SELECT 
    *
FROM
    result LEFT OUTER JOIN 
    ((SELECT * FROM SQA AS sqa JOIN SA AS sa USING (sa_oid) WHERE sqa.sq_oid = 1)
    AS tmp1) ON tmp1.sa_oid = result.re_as

WHERE
    result.re_p = 1 AND 
    result.re_s = 1 AND
    result.re_q = 1)

UNION

(SELECT 
    *
FROM
    result RIGHT OUTER JOIN 
    ((SELECT * FROM SQA AS sqa JOIN SA AS sa USING (sa_oid) WHERE sqa.sq_oid = 1)
    AS tmp2) ON tmp2.sa_oid = result.re_as

WHERE
    result.re_p = 1 AND 
    result.re_s = 1 AND
    result.re_q = 1)

Again, the two left and right joins work individually but seem to generate a syntax error if put together with the UNION operator. Any ideas? Are there name collisions? Or is a FULL OUTER JOIN not possible in this case?

Any feedback is very much appreciated! Also, please excuse the triviality of the question (if it is trivial).

EDIT:

"Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ON tmp2.sa_oid = result.re_as

    WHERE
        result.re_p = 1 AND 
        result.re' at line 20"
  • 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-18T08:12:59+00:00Added an answer on June 18, 2026 at 8:12 am
    Try this:
    
    (SELECT 
        *
    FROM
        result LEFT OUTER JOIN 
        (SELECT * FROM surveyquestion_answers AS sqa JOIN surveyanswer AS sa USING (sa_oid) WHERE sqa.sq_oid = 1)
        AS tmp1 ON tmp1.sa_oid = result.re_answer
    
    WHERE
        result.re_page = 1 AND 
        result.re_survey = 1 AND
        result.re_question = 1)
    
    UNION
    
    (SELECT 
        *
    FROM
        result RIGHT OUTER JOIN 
        (SELECT * FROM surveyquestion_answers AS sqa JOIN surveyanswer AS sa USING (sa_oid) WHERE sqa.sq_oid = 1)
        AS tmp2 ON tmp2.sa_oid = result.re_answer
    
    WHERE
        result.re_page = 1 AND 
        result.re_survey = 1 AND
        result.re_question = 1)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to formulate an SQL FULL OUTER JOIN, which includes all values in
I'm trying to use Linq to SQL to do a full outer join. I
I'm trying to implement a query in LINQ that uses a left outer join
I am trying to hold a file full of templates that can be loaded
I am trying to join two EJB's using EJBQL (with an underlying MySQL data
I am trying to match full word from some lines, wanted to know how
I have a WinForms app that I am trying to make full screen (somewhat
I need to add value condition to the FULL OUTER JOIN. I.e. I'm triyng
I'm obviously not trying to play full spectrum audio, but is there some way
I am trying to full text search a column, but also be able to

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.