0 votes 0 votes Databases sql + – Sourabh Kumar asked May 6, 2016 • edited Feb 15, 2019 by Cristine Sourabh Kumar 967 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 1 votes 1 votes In Exists subquery count(*) always results to be true so that all the tuples of table T is displayed shivanisrivarshini answered May 24, 2016 • selected May 27, 2016 by Arjun shivanisrivarshini comment Share Follow See all 4 Comments See all 4 4 Comments reply vijaycs commented May 27, 2016 reply Follow Share How Exists subquery returns true ?? 0 votes 0 votes shivanisrivarshini commented May 29, 2016 reply Follow Share if its just * in subquery it returns false but its count(*) because of this exists returns true 0 votes 0 votes Akriti sood commented Jun 7, 2016 reply Follow Share but b does not has a 2 value..how come it is true then?? 0 votes 0 votes shivanisrivarshini commented Jun 7, 2016 reply Follow Share ur correct @Akriti sood but the thing is mainly in count(*) if count(*) is present in subquery of exists irrespective of query i.e even b=2 tuple doesn't present but the count(*) evaluates the query is true so if exists subquery is true then all tuples of table are resulted 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Here in the inner query we have EXISTS clause Exists return true when it get value or the inner query return at least 1 record Here Select count (*) From T where B =2 return a row 2 10 (COUNT =1 ) HENCE NO OF ROWS RETURNED = 1 Dexter answered May 6, 2016 Dexter comment Share Follow See all 4 Comments See all 4 4 Comments reply Sourabh Kumar commented May 7, 2016 reply Follow Share B value in any row not 2.so,how inner query return row 2 10 I think inner query return 0.but after this what wil happen? 0 votes 0 votes namanom1 commented May 27, 2016 reply Follow Share so 0 (zero) is a returned value that means...the inner query has returned something.. EXISTS will treat it as TRUE as some value has been returned, and so the number of rows returned will be 3 0 votes 0 votes sonu commented May 27, 2016 reply Follow Share @namanom1 So if exists return NULL than only no row will be selected ryt?? 0 votes 0 votes namanom1 commented May 28, 2016 reply Follow Share it wont return NULL...either TRUE or FALSE...if no data is found in the EXIST part then it will return a FALSE.. 0 votes 0 votes Please log in or register to add a comment.