Given a table containing class and students, need to find the diff in students I have class_students table where given 2 class ids I need to find the diff in students.
This is sql fiddle that I used,
http://sqlfiddle.com/#!9/dba48e/11
Any help here.
Use, for example

SELECT student_id
FROM class_students
GROUP BY student_id
HAVING SUM(class_id = 1) &gt; 0
   AND SUM(class_id != 1) = 0


More informative is

SELECT student_id, GROUP_CONCAT(DISTINCT class_id) classes_in
FROM class_students
GROUP BY student_id
HAVING COUNT(DISTINCT class_id) &lt; ( SELECT COUNT(DISTINCT class_id)
                                    FROM class_students )


PS. Recommendation - define (class_id, student_id) (or in backward fields order) as unique/primary index - it will forbid duplicated records.