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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:01:38+00:00 2026-05-21T02:01:38+00:00

So I’m trying to build what amounts to a report from several MySQL views

  • 0

So I’m trying to build what amounts to a report from several MySQL views that I have already written. Each one of the views has three columns and looks something like this

View ABC:
-------------------------------
|    A    |    B    |    C    |
|         |         |         |
-------------------------------
|  data1  |   asdf  |    3    |
|  data1  |   jkl;  |    1    |
-------------------------------

Assume that there are three other views which are structured identically, named DEF, GHI, and JKL. In view DEF, the last column is named D, in GHI the last column is named E, and in JKL the last column is named F.

In each of the views, the value in the A column should be the same for all rows (It’s for another way to solve the problem I’m having which doesn’t completely rely on MySQL, but I’m sure there must be a better way).

What I’m trying to do is this:

View ABC:
-------------------------------------------------------------
|    A    |    B    |    C    |    D    |    E    |    F    |
|         |         |         |         |         |         |
-------------------------------------------------------------
|  data1  |   asdf  |    3    |    0    |    2    |    7    |
|  data1  |   jkl;  |    1    |    1    |    0    |    0    |
|  data2  |   lmno  |    0    |    1    |    2    |    17   |
-------------------------------------------------------------

So my first thought would be to LEFT OUTER JOIN on the B field, like so:

SELECT ABC.*, DEF.D, GHI.E, JKL.F 
FROM ABC 
LEFT OUTER JOIN DEF ON ABC.B = DEF.B 
LEFT OUTER JOIN GHI ON ABC.B = GHI.B
LEFT OUTER JOIN JKL ON ABC.B = JKL.B

That’s all well and good; it fills in zeroes with NULL, which I can easily COALESCE into 0. However, the issue is if there is a row in one of the DEF, GHI, or JKL views where the username doesn’t match one in ABC; that row is simply omitted from my SELECT (due to this being a LEFT OUTER JOIN). RIGHT OUTER JOIN suffers the same issue.

Is there a way to perform a full outer join such that any B that occurs in any of the four views will have a row in my SELECT? I’ve tried embedding some other selects, but unfortunately that seems to repeat rows and data values in an unacceptable way in the result of the SELECT. From looking at the documentation, I don’t think MySQL supports a full outer join (at least not that I could find), and even if it did, I don’t know how I could get the username from the other views into the username column in the SELECT statement.

  • 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-05-21T02:01:39+00:00Added an answer on May 21, 2026 at 2:01 am

    What you are looking for is called a FULL OUTER JOIN. Unfortunately it doesn’t seem to be supported directly in MySQL, however you can achieve the result by doing UNIONs of LEFT JOINs and RIGHT JOINs.

    From: http://dev.mysql.com/doc/refman/5.0/en/join.html

    Posted by barbarina on September 12 2006 2:17pm

    You can emulate FULL OUTER JOIN using
    UNION (from MySQL 4.0.0 on):

    with two tables t1, t2:

    SELECT * FROM t1 LEFT JOIN t2 ON t1.id = t2.id 
    UNION 
    SELECT * FROM t1 RIGHT JOIN t2 ON t1.id = t2.id
    

    with three tables t1, t2, t3:

    SELECT * 
    FROM 
      t1 
      LEFT JOIN t2 ON t1.id = t2.id 
      LEFT JOIN t3 ON t2.id = t3.id 
    UNION 
    SELECT * 
    FROM t1 
      RIGHT JOIN t2 ON t1.id = t2.id 
      LEFT JOIN t3 ON t2.id = t3.id 
    UNION 
    SELECT * 
    FROM 
      t1 
      RIGHT JOIN t2 ON t1.id = t2.id 
      RIGHT JOIN t3 ON t2.id = t3.id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I have a view passing on information from a database: def serve_article(request, id): served_article
I am trying to loop through a bunch of documents I have to put

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.