• edited by
630 views
1 1 vote

How will this query execute?

Q1: Select pno from project

Q2: select pno from works where employee.eno=works.eno

Now Q1 except Q2 will all projects which do not have an employee working on it. So the outer query should give: All employees who are working on some project.

But answer is: Employees working on all projects.

Consider the following relations schema
employee (eno, ename, salary)
project (pno, pname, duration)
works (eno, pno)

Select ename from employee where not exists
(select pno from project)
except
(select pno
from works_on
where employee eno = works_on. eno):

The above query finds name of the employee who works_on $\qquad$

  1. Exactly one project
  2. Atleast one project
  3. Atmost one project
  4. Every project.
    Your Answer: B
    Correct Answer :D

1 Answer

0 0 votes
Query1  selects all the PNo from project table.

Query2 is a correlated query that returns that Pno in which an employee works.

Query1 except Query2. returns in which project that particular employee did not work.

 if Query1 except Query2 is an empty set , the outer query returns the employee name.
So we can say, Query1 except Query2 is an empty set if an employee works in all project.
Position:
Show:

Related questions

1 1 vote
1 1 answer
1.2k
1.2k views
Priyansh Singh asked Mar 29, 2019
1,186 views
Given the following schema:employees(emp-id, first-name, last-name, hire-date, dept-id, salary)departments(dept-id, dept-name, manager-id, location-id)You want to display...
1 1 vote
1 1 answer
3.4k
3.4k views
Na462 asked Jan 19, 2019
3,419 views
1 1 vote
1 1 answer
2.6k
2.6k views
Shubhanshu asked Dec 24, 2018
2,614 views
According to me it should be – “Retrieve the names of all students with a lower rank, than all students with age < 18 ”
0 0 votes
1 1 answer
1.5k
1.5k views
Na462 asked Jun 29, 2018
1,517 views