title: Mysql query to see if a member has done a lesson
body: <p>I have 2 tables: "members_info" and "members_lesson".</p>
  
  <p>Let's say in members_info I have the fields member_id, first_name, last_name
  In members_lesson I have members_lesson_id, lesson_id, member_id</p>
  
  <p>I want to create a query where I can see the members that have done one lesson but havent done another one. I tried this query:</p>
  
  <pre><code>SELECT members_info.member_id
     FROM members_info
     JOIN member_lessons ON members_info.member_id = member_lessons.member_id
     WHERE member_lessons.lesson_id =6 AND  member_lessons.lesson_id !=7
  </code></pre>
  
  <p>But that query is not working. It works when I only check if the member has done a lesson, but if I want to see if the member has not done another one it doesnt work. Any ideas? Thanks!</p>
  
  <p><strong>EDIT --</strong></p>
  
  <p>I tried this:</p>
  
  <pre><code>SELECT members_info
  FROM members_info
  WHERE member_id IN (SELECT member_id FROM member_lessons WHERE lesson_id = 6)
  AND member_id NOT IN (SELECT member_id FROM member_lessons WHERE lesson_id = 7)
  </code></pre>
  
  <p>It does work, but im not sure about performance. Is that way ok? Thanks!</p>