title: SQLite simplify union of left outer join
body: <p>I inherited some monster SQL queries and I would like to simplify/ shorten them as much as possible.</p>
  <p>One of them is:</p>
  <pre><code>SELECT 
                * 
              FROM 
                (
                  SELECT 
                    $columnsFromBothTables
                  FROM 
                    table_abc
                    left outer join table_xyz using profile_id 
                  union 
                  select 
                    $columnsFromBothTables
                  from 
                    table_xyz 
                    left outer join table_abc using profile_id
                ) 
  </code></pre>
  <p>It looks weirdly redundant.<br />
  Is there a way to simplify it to sth like?</p>
  <pre><code>SELECT * FROM (
      SELECT $columns FROM table_abc MAGIC_OPERATION table_xyz
  )
  </code></pre>
  <p>Isn't it a FULL OUTER JOIN?</p>
  <p><strong>Updates</strong>:
  My understanding is that both tables have M-1 relationship to &quot;profile&quot; table.</p>
  <p>They do not have direct relationship to each other</p>