title: How to query two tables and return all records from first, regardless on whether exist in the second table
body: <p>I have a couple of tables with the following structure: </p>
  
  <p>Table application:</p>
  
  <pre><code>AppId   Name
  ====================
  1       App 01
  2       App 02
  3       App 03
  </code></pre>
  
  <p>Table SubscribedApplications</p>
  
  <pre><code>SubAppId   AppId    SubId
  ==============================
  1          1        99901
  </code></pre>
  
  <p>What I need to get is the table application with all matches of SubscribedApplications, and if there's no record in it, get null values, filtered by the SubId. Something like this: </p>
  
  <p>Expected result: </p>
  
  <pre><code>AppId   Name    SubAppId   SubId
  ==================================
  1       App 01  1          99901
  2       App 02  NULL       NULL
  3       App 03  NULL       NULL
  </code></pre>
  
  <p>I thought of doing a right outer join like this: </p>
  
  <pre class="lang-sql prettyprint-override"><code>select Applications.AppId as AppId,     
      Applications.Name as AppName,         
      SubscribedApplications.SubAppId as SubAppId,     
      SubscribedApplications.SubId as SubId,       
  from SubscribedApplications 
      right outer join Applications on Applications.AppId = SubscribedApplications.AppId
  where SubscribedApplications.SubId is null
      or SubscribedApplications.SubId= '99901' 
  </code></pre>
  
  <p>However, this approach is not working. If I create a record in subscribedapplications for, say, subid 99901, I get three records, but if I query for 99902 I only get two records. I can't find out why. I have tried several variants of this, including using in (null, '99901') in the where clause, to no avail. </p>
  
  <p>My other alternative would be to retrieve all records from Application table, then the records from SubscribedApplication record and in (C#) code evaluate which ones to keep, but I'd like to have it in one query, if possible. </p>