select count(*) from long_table where exam_id=? and question_id=? and answer=? and student_id in (select student_id from long_table where exam_id=? and question_id=? and answer=?) #### "where exam_id=? and answer_$x=?" for $x (1..50);