2 2 votes Consider the following database table : $Emp(\underline{Eid}, Ename, age)$ $Project(\underline{Pid}, Pname,budget)$ $Works for(\underline{Eid Pid})$ Select $Eid$ from $Emp$ $E$ where $age > 30$ and not Exists $(select$ $Pid$ $\text{From project P}$ $\text{where Pname = 'database' and not exist (select Pid}$ $\text{from works W}$ $\text{where W.Eid = E.Eid}$ $\text{and W.Pid = P.Pid))}$ What does the following query return? More specifically, what does the inner most query do? Would it run only for those eid with age>30 and pid="database" or for all of them? Databases sql databases + – Nymeria 916 views answer comment Share Follow Print See all 5 Comments 5 5 Comments reply hs_yadav commented Jan 17, 2018 reply Follow flag "" all the employee for which it doesn't exits that they doesn't work with all project having name "database"... in other word it s returning name of employee working with all project name database??? 0 0 replyShare Nymeria commented Jan 17, 2018 reply Follow flag Yes correct. Can you please help me understand the solution? Also the age>30. 0 0 replyShare hs_yadav commented Jan 17, 2018 reply Follow flag yes...i missed that ...age>30.... and i'm not getting that how to help u in this....but try this... first of all read the inner query .... here they are selecting all the project name database and employee working for all that project...and not considering them...means S1. negation of (employee workjing for all the project name database having age>30) and now come to outer query.... again they are making the negation of abouve statement ... negation of (S1)... S1 ((employee working for all the project name database having age>30) .... 1 1 replyShare Nymeria commented Jan 17, 2018 reply Follow flag I was making a stupid mistake !! :P Thanks a lot for your efforts :) 0 0 replyShare Jeevesh commented Mar 11, 2018 reply Follow flag These all are correlated subqueries right ? For one tuple of employee relation we would check combinations of project and works for relations. Just to check my understanding ! 0 0 replyShare Please log in or register to add a comment.