title: MySQL to MongoDB
body: <p>I have this query:</p>
  
  <pre><code>        SELECT DISTINCT 1 as table_id, users.id, users.username, a.titles_name title1, b.titles_name as title2, contacts.accepted
          FROM users
          LEFT JOIN contacts ON users.id = contacts.contact_id
          LEFT JOIN titles as a ON a.id = users.title_1
          LEFT JOIN titles as b ON b.id = users.title_2
          WHERE contacts.request_id = ' + $this-&gt;session-&gt;userdata('user_id') . '
          UNION DISTINCT
          SELECT DISTINCT 2 as table_id, users.id, users.username, a.titles_name title1, b.titles_name as title2, contacts.accepted
          FROM users
          LEFT JOIN contacts ON users.id = contacts.request_id
          LEFT JOIN titles as a ON a.id = users.title_1
          LEFT JOIN titles as b ON b.id = users.title_2
          WHERE contact_id = ' . $this-&gt;session-&gt;userdata('user_id')
  </code></pre>
  
  <p>Would it be possible to do something similar in mongodb?</p>