In the above case i only want to fetch the empid 2 . Neither 1 nor 3, as only empid = 2 satisfy both condition that is for empid = 2 when accessid = 1, accessval is 'all' and when accessid = 2, accessval is 'read' empid = 1 record is not expected, as in this case when accessid = 1, accessval is 'all' but when accessid = 2, accessval is something other than 'read' empid = 3 record is also not expected, as in this case when accessid = 2, accessval is 'read' but when accessid = 1, accessval is something other than 'all'