848 views
0 votes
0 votes
SELECT Lname, Fname  
FROM EMPLOYEE  
WHERE NOT EXISTS (
    SELECT *  
    FROM WORKS_ON B
    WHERE ( B.Pno IN (
        SELECT Pnumber
        FROM PROJECT
        WHERE Dnum=5 )
        AND  NOT EXISTS (
            SELECT *
            FROM WORKS_ON C
            WHERE C.Essn=Ssn
            AND C.Pno=B.Pno )));


Works_On table has details of projects the employee works on and project contains details of various projects running in various department.

What details does the above query fetches? Please explain the steps to solve this query.

2 Answers

0 votes
0 votes
1.  Select *from works_on c...... query run nd select those tuple which fullfil givn conditn now not exist means disply those tuple which r not selected

2. Now query select pnumber........run nd disply those pnumbr whose dnum = 5

3. Now query select * from works_ on b......nd select those tuple whose b.pno is belongs to above selected tuple

4. Now query select lname..... run nd bcz of not exist it disply those tuple from employee table which r not selected by above 3rd point and it is our final result..
0 votes
0 votes
Gives details of employees who either don't work on a project in department no. 5 OR works on a project with essn=ssn (social security number?)

Related questions

0 votes
0 votes
2 answers
1
print asked Jan 21, 2022
483 views
Source Made Easy Test SeriresCan anyone please tell me the answer for this, with explaination. According to me it will give the customer who buy from atleast one store, b...
0 votes
0 votes
2 answers
3
0 votes
0 votes
0 answers
4
shikharV asked Jan 4, 2016
392 views
I couldn't understand its solution. Please explain