title: Need to join 2 tables with more than 200K data. How to prepare the query?
body: <p>I have to join 2 tables which are currently holding more than 200K data each. I have members and orders table. I would like to get members who didn't order anything.</p>
  
  <p>I tried following SQL queries;</p>
  
  <p><strong>Structure</strong> (just listing what I need)</p>
  
  <pre><code>ORDERS                  MEMBERS
  id                      id
  member_id               fullName
                          email
                          landLine
                          cellPhone
  </code></pre>
  
  <p><strong>Query1</strong></p>
  
  <pre><code>$sql  = 'SELECT '.PREFIX.'members.fullName
             , '.PREFIX.'members.email
             , '.PREFIX.'members.landLine
             , '.PREFIX.'members.cellPhone, ';
  $sql .= 'FROM '.PREFIX.'members';
  $sql .= 'LEFT JOIN ';
  $sql .= PREFIX.'orders';
  $sql .= ' ON ';
  $sql .= PREFIX.'members.id = '.PREFIX.'orders.member_id';
  $sql .= ' WHERE '.PREFIX.'orders.member_id IS NULL LIMIT 50';
  </code></pre>
  
  <p><strong>Query 2</strong></p>
  
  <pre><code>$sql2  = 'select id, fullName, email, landLine, cellphone 
            from '.PREFIX.'members 
            where '.PREFIX.'members.id not in 
               (select member_id from '.PREFIX.'orders) 
            LIMIT 50';
  </code></pre>
  
  <p><strong>Query 3</strong></p>
  
  <pre><code>$sql3  = 'select id, fullName, email, landLine, cellphone 
            from '.PREFIX.'members m 
            where not exists 
              (select null from '.PREFIX.'orders o where s.members_id = o.id) 
            LIMIT 50';
  </code></pre>
  
  <p>All 3 queries so far didn't work. More than a minute passed, I am still waiting for the results.</p>
  
  <p>What is the most elegant way to do this? Which one is faster and using less resources? I don't see anything wrong here why it would work but for some reason it just can't list.</p>
  
  <p>Thank you for your help in advance.</p>