title: PostgreSQL - Merge two selects queries
body: <p>I have two tables : </p>
  
  <p><strong><em>company</em></strong> and  <strong><em>users</em></strong></p>
  
  <p>the users table:</p>
  
  <pre><code>    id   |   name   |   cpf     |   phone_number  | company_id
  
      1    |   Jonh   | 111.11.11 |   1111-1111     |    1
  
      2    |   Marie  | 222.22.22 |   2222-2222     | 
  
      3    |   Paul   | 333.33.33 |   3333-3333     |    3
  
      4    |   Luna   | 444.44.44 |   4444-4444     |    1
  
      5    |   Leo    | 555.55.55 |   5555-5555     |    
  </code></pre>
  
  <p>the company table:</p>
  
  <pre><code>id   |   name       |   cnpj      |   phone_number | company_data | consumer
  
  1    |  companyA    | 111.1111.11 |   1111-1111    |     data1    | true
  
  2    |  companyB    | 222.2222.22 |   2222-2222    |     data2    | true
  
  3    |  companyC    | 333.3333.33 |   3333-3333    |     data3    | false
  </code></pre>
  
  <p>I want to select all the users where <code>company_id IS NULL</code> and all the companies
  where  <code>consumer is true</code></p>
  
  <p>What I'm trying to do is something like this :</p>
  
  <pre><code> Select u.name as name,
            u.cpf as document,
            u.phone_number as phoneNumber,
            'false' as company
            FROM users u 
            WHERE company_id is NULL
  
     UNION
  
     Select c.name as name,
            c.cnpj as document, 
            c.phone_number as phoneNumber,
            c.company_data as companyData
            'true' as company
            FROM company c
            WHERE c.consumer = 'true'
  
    ORDER BY id
  </code></pre>
  
  <p>And the answer I want is :</p>
  
  <pre><code>id   |   name       |   document  |   phone_number  | companyData |  company
  
  1    |  companyA    | 111.1111.11 |   1111-1111     |   data 1    |   true
  
  2    |  companyB    | 222.2222.22 |   2222-2222     |   data 2    |   true
  
  2    |   Marie      | 222.22.22   |   2222-2222     |             |  false
  
  5    |   Leo        | 555.55.55   |   5555-5555     |             |  false
  </code></pre>
  
  <p>I can accept a answer with the columns <code>cpf</code> and <code>cnpj</code> separed and the results null if it doens't apply to the selected entity. In this way I would not need the <code>company</code> column</p>