title: Oracle SELECT WHERE value exists or doesn't exist
body: <p>I have 3 tables; <code>CASES</code>, <code>USERS</code> and <code>USER_META</code>. For this issue you need to know that the <code>USER_META</code> table has 3 columns; <code>user_id</code>, <code>meta_key</code> and <code>meta_value</code></p>
  
  <p>Each user is associated with many <code>CASES</code> and each <code>USER</code> is associated with many <code>USER_META</code></p>
  
  <p>My current query is like this</p>
  
  <pre><code>SELECT CASES.*, USERS.*, USER_META.*
  FROM CASES
  JOIN USERS ON USERS."user_id" = CASES."user_id"
  JOIN USER_META ON USER_META_"user_id" = USERS."user_id"
  </code></pre>
  
  <p>The problem with this approach is that each USER has <strong>A LOT</strong> of USER_META so my result set has too many rows. How can I rewrite this query so that I can select only the USER_META where the USER_META."meta_key" is equal to a certain value <strong>yet still get the result if they do not have this USER_META."meta_key" set yet</strong></p>
  
  <p>For example:</p>
  
  <pre><code>SELECT CASES.*, USERS.*, USER_META.*
  FROM CASES
  JOIN USERS ON USERS."user_id" = CASES."user_id"
  JOIN USER_META ON USER_META_"user_id" = USERS."user_id"
  WHERE USER_META."meta_key" = 'my_key'
  </code></pre>
  
  <p>This would work great but not all users have a value of "my_key" in the "meta_key" column and we still need to view their CASE. For users that do not have the "meta_key" the result should just return the CASE and USER columns.</p>
  
  <p>How can I rewrite this query so it gets the result for both users with this meta_key and without?</p>
  
  <p>Thanks, I hope this makes sense.</p>