6 6 votes Plz explain both queries! Databases databases sql + – Lokesh . 2.7k views answer comment Share Follow Print See all 18 Comments 18 18 Comments reply Ajay Jadhav commented Jan 13, 2017 reply Follow flag I think both queries won't work whats the answer 0 0 replyShare Lokesh . commented Jan 13, 2017 reply Follow flag ans given is Q1 0 0 replyShare dd commented Jan 13, 2017 i edited by dd Jan 13, 2017 reply Follow flag Q1 : Assuming CSE branch student exist in the database table Student. A tuple $t_1$ from Student table will be included in the result of Q1, when the corresponding inner query result is empty. if $t_1$.$\text{rank}$ is less than the all CSE student ranks,then only inner query results becomes empty. Q2: If CSE dept ranks are = $\left \{ 4,5,6,7 \right \}$ A tuple $t_1$ from Student table will be included in the result of Q2, when $t_1$.$\text{rank}$ is less than any one of $\left \{ 4,5,6,7 \right \}$. Obviously CSE topper will not be in the result of Q2 0 0 replyShare Lokesh . commented Jan 13, 2017 reply Follow flag this means Q1 is wrong?? 0 0 replyShare dd commented Jan 13, 2017 reply Follow flag I think wrong ! What you say ? 0 0 replyShare Lokesh . commented Jan 13, 2017 reply Follow flag in question they are asking anyone...but here we are getting all...I selected none but they gave q1 as ans thats why I asked here 0 0 replyShare dd commented Jan 13, 2017 reply Follow flag what is wrong in my comment above ? for Q2 ? 0 0 replyShare Rahul Jain25 commented Jan 13, 2017 reply Follow flag This is basically a gate question that has been asked previously but relation names and scenario has been changed. And Q1 is correct. @Arjun sir has explained that question brilliantly. You could refer that. https://gateoverflow.in/1259/gate2007-61 0 0 replyShare Lokesh . commented Jan 13, 2017 reply Follow flag its correct but in ANY when inner query returns empty ...then result will be false thats why I think Q2 is also incorrect 0 0 replyShare Samujjal Das commented Jan 13, 2017 reply Follow flag They tried to copy this question with a little modification and failed horribly :p https://gateoverflow.in/1259/gate2007-61 0 0 replyShare Rahul Jain25 commented Jan 13, 2017 reply Follow flag Q2 is definately wrong bcoz it will give even that person which has rank less than even one individual of CS, but we want only those person who have rank smaller than all individuals of CS. Q1 is the answer. Remember here we want persons whose rank is smaller than everyone in CS. 0 0 replyShare dd commented Jan 13, 2017 reply Follow flag @rahul you could say ..our interpretation for "anyone" was wrong in the particular QS. Thanks for the QS link quoting from that QS comments: anyone here refers = everyone in the CSE dept. right ? @rahul ? 0 0 replyShare Rahul Jain25 commented Jan 13, 2017 reply Follow flag It don't think they have failed in changing this question. I find this questions correct and Q1 as the only answer. 1 1 replyShare Rahul Jain25 commented Jan 13, 2017 reply Follow flag @dbashish, yes. I will say again go the link. There one comment is done by arjun sir, really an excellent one, where he has used a set and explained what anyone means. Read all comments. 1 1 replyShare Samujjal Das commented Jan 13, 2017 reply Follow flag Yes correct. I said so seeing the discussions going on here previously. Sorry!! 0 0 replyShare akshay_845 commented Jan 25, 2017 reply Follow flag @habibkhan can you tell me this 0 0 replyShare joshi_nitish commented Jul 9, 2017 reply Follow flag why are you mentioning my name here??..i hadn't commented or answered here.... are you asking me to verify this??? 0 0 replyShare joshi_nitish commented Jul 9, 2017 reply Follow flag see, neither "s2.rank<=s1.rank" nor "s2.rank<s1.rank" will work... in case of "s2.rank<=s1.rank"...s1 will be selected only if it is less than everyone...moreover there is one more problem in this query, 'what if s1 is from CSE department, than he will never get selected because there will come a point where comparison s1.rank<=s1.rank will be done and therefore notexist will contain some tupple and s1 will not be selected... in case of "s2.rank<s1.rank"...s1 will not be selected if it is greater than anyone in cse(or we can say s1 will be selected only if it less than or equal to everyone)... 0 0 replyShare Please log in or register to add a comment.