 <p>I think this is what you are after:</p> <pre><code>Select student_course_modules.module_id from student_course_modules left join student_courses on student_courses.id = student_course_modules.student_course_id where student_courses.course_id="1" And student_courses.student_id="ST_2014_1" And student_course_modules.module_id IN ("'1'")) </code></pre>