title: Select the result of subquery when the outer query results null
body: <p>Im using <code>postgres 9.4</code>. I have two tables <code>tblcomponent</code> and <code>tblprofile</code> with no foreign key reference.</p>
  
  <p>I want to select the data from both the tables. The relationship goes like</p>
  
  <p><code>tblcomponent</code> -> <code>tblprofile</code></p>
  
  <p>If the required data is not found in <code>tblprofile</code>, then only <code>tblcomponent</code> data must be selected. If the <code>tblcomponent</code> itself does not contain the requested data, then data need not be fetched.</p>
  
  <p>Query:</p>
  
  <pre><code>SELECT subquery1.pk_szid, subquery1.xmldata, tblprofile.pk_szid, tblprofile.xmldata
  FROM tblprofile,
   (SELECT tblcomponent.pk_szid, tblcomponent.xmldata 
    FROM tblcomponent WHERE pk_szid != 'DEFAULT' ) subquery1
  WHERE  
  CAST((xpath('/Profile/ComponentIDs/ComponentID[@Family="Flow"]/text()', tblprofile.xmldata))[1] AS TEXT) = subquery1.pk_szid
  </code></pre>
  
  <p>The above query returns if the data exists in both the table. How to get the data from <code>subquery1</code> when the outer query, i.e., where clause fails?</p>
  
  <p>For example:</p>
  
  <p><code>tblcomponent</code>:</p>
  
  <pre><code>| pk_szid | xmldata        |
  +---------+----------------+
  | a1      |  xmldata       |
  | a2      |  xmldata       |
  | a3      |  xmldata       |
  </code></pre>
  
  <p><code>tblprofile</code>:</p>
  
  <pre><code>| pk_szid | xmldata        |
  +---------+----------------+
  | b1      |  xmldata       | // contains a1
  | b2      |  xmldata       | // does not contain any of tblcomponent.pk_szid
  </code></pre>
  
  <p>Here, 'b1' record's xmldata contains tblcomponent.pk_szid. When I give 'a1', the result for above query will be,</p>
  
  <pre><code>| pk_szid      | xmldata     |   pk_szid    |  xmldata     |
  +--------------+-------------+--------------+--------------+
  | a1           | xmldata     |     b1       |   xmldata    |
  </code></pre>
  
  <p>When I give 'a2',</p>
  
  <pre><code>  | pk_szid      | xmldata     |   pk_szid    |  xmldata     |
    +--------------+-------------+--------------+--------------+
  </code></pre>
  
  <p>I want something like,</p>
  
  <pre><code> | pk_szid      | xmldata     |   pk_szid    |  xmldata     |
   +--------------+-------------+--------------+--------------+
   | a2           | xmldata     |              |              |
  </code></pre>
  
  <p>How to fetch this from <code>subquery1</code>?</p>