SELECT DISTINCT (s.sid),class,division,fatmobile,rollno,stdname,regno FROM termdetails t WHERE t.sid NOT IN ( SELECT s.sid from studentdetails s WHERE (s.class = '" + ClassWiseDrop1.SelectedValue + "' AND s.division = '" + ClassWiseDrop2.SelectedValue + "'))
Why dont you try making use of the above code. I think this might help. Or try using the UNION operator if you come across any more problems.
NOT IN Usage[
^]
NOT IN Usage 2[
^]
Here is an example of how NOT IN can be used.