title: How to get a column from first table on UNION in postgresql?
body: <p>I have a requirement to fetch all files which is created_by "a@a.com" or shared_to "a@a.com". Below are the 2 tables which is needed to achieve the result.</p>
  
  <p>filter_analysis_store</p>
  
  <pre><code>fa_identifier,created_by,case_no
  FA000179,a@a.com,01998455
  FA000183,a@a.com,01998455
  FA000184,a@a.com,02039960
  FA000185,a@a.com,02039960
  FA000187,a@a.com,02039596
  FA000189,a@a.com,02039960
  FA000190,a@a.com,02029418
  FA000191,a@a.com,02029418
  FA000192,a@a.com,02039596
  FA000193,a@a.com,02039596
  FA000194,a@a.com,02039596
  FA000195,a@a.com,01912596
  FA000199,a@a.com,02039596
  </code></pre>
  
  <p>share_analysis_store</p>
  
  <pre><code>fa_identifier,shared_by,shared_to
  FA000173,p@p.com,a@a.com
  FA000196,p@p.com,a@a.com
  FA000180,r@r.com,a@a.com
  FA000198,r@r.com,a@a.com
  </code></pre>
  
  <p>I used "UNION" to come up with a query which gives me the result but I had to give empty string for 2nd query. How to get respective case_no for missing ones?</p>
  
  <pre><code>select fas.fa_identifier, fas.case_no as case_no from filter_analysis_store fas  
  where created_by like 'a@a.com' UNION 
  select sas.fa_identifier, '' from share_analysis_store sas
  where shared_to like 'a@a.com';
  </code></pre>
  
  <p>Output of above query</p>
  
  <pre><code>FA000184    02039960
  FA000183    01998455
  FA000193    02039596
  FA000199    02039596
  FA000180    
  FA000189    02039960
  FA000195    01912596
  FA000185    02039960
  FA000194    02039596
  FA000190    02029418
  FA000191    02029418
  FA000173    
  FA000192    02039596
  FA000198    
  FA000179    01998455
  FA000187    02039596
  FA000196    
  </code></pre>