0 votes 0 votes i got 2 tuples but answer given is 3 Databases sql + – set2018 asked Nov 10, 2017 set2018 572 views answer comment Share Follow See all 10 Comments See all 10 10 Comments reply joshi_nitish commented Nov 10, 2017 reply Follow Share answer will be 3 only, because if count* is present in EXISTS, then EXISTS will always be true irrespective of further query, because count* in worst case will return 0(non null value), or we can say that count* will either return 0 or some non zero value in every case(even if NULLs are present) and in both case EXISTS will return true.. so above query is equivalent to, select * from R1 as T1 // because we know that EXISTS will always return true. 4 votes 4 votes set2018 commented Nov 10, 2017 reply Follow Share but where condition fails for value 6 0 votes 0 votes joshi_nitish commented Nov 10, 2017 reply Follow Share but then also count* will return 0 which will make EXISTS true... 0 votes 0 votes just_bhavana commented Nov 10, 2017 reply Follow Share @nitish as per my understanding EXISTS tests whether a set is non-empty and returns true if non-empty. So here when count(*) returns 0, this result is assumed be non-empty right ? 0 votes 0 votes Anu007 commented Nov 10, 2017 reply Follow Share yes.... 0 votes 0 votes set2018 commented Nov 10, 2017 reply Follow Share just_bhavana for inner query why we are not checking where condition .it is fine that count* will give all values then what is the use of where condition? 0 votes 0 votes joshi_nitish commented Nov 10, 2017 reply Follow Share @bhavna, yes... 0 votes 0 votes just_bhavana commented Nov 10, 2017 reply Follow Share @set2018 here where condition is redundant as EXISTS is returning true always 1 votes 1 votes joshi_nitish commented Nov 10, 2017 reply Follow Share @set2018 it is just like c=1 || a+b-(c&&d) ; why to check second operand of OR(||), when you know first operand always make it true, no matter what is second operand 1 votes 1 votes set2018 commented Nov 10, 2017 reply Follow Share thnq just_bhavana & joshi_nitish got the mistake 1 votes 1 votes Please log in or register to add a comment.