title: Optimizing query to grab results from two tables
body: <p>Lets say I have a db table called Document that contains rows for all the documents I own. I have another db table called Shared that has records for all documents (owned by other people) that I can read/write to.</p>
  
  <pre><code>Document
  id
  type
  user_id
  permissions
  
  Shared
  id
  document_id
  used_id
  permissions
  </code></pre>
  
  <p>I was trying to write a query that would get me back all documents that I (given a user_id) own and have access to. My attempt is something like this:</p>
  
  <pre><code>Select id, type, user_id, permissions from Document where user_id = 123
  union all
  Select id, type, user_id, permissions from Document where id in
                                     (select document_id from shared where user_id = 123)
  </code></pre>
  
  <p>The above seems a little bit verbose so I was wondering if there was a more succinct/efficient way to write the above (if it works at all)</p>