1,411 views
1 1 vote
These queries are same they are retriving the fname ,lname of employee who have dependent with same first name ,lname as that of employee - my doubt is that in second query why we are not taking the condition e.ssn=d.essn

1): SELECT E.Fname, E.Lname
FROM EMPLOYEE AS E
WHERE EXISTS ( SELECT *
FROM DEPENDENT AS D
WHERE E.Ssn=D.Essn AND E.Sex=D.Sex
AND E.Fname=D.Dependent_name);

2)SELECT E.Fname, E.Lname
FROM EMPLOYEE AS E
WHERE E.Ssn IN ( SELECT Essn
FROM DEPENDENT AS D
WHERE E.Fname=D.Dependent_name
AND E.Sex=D.Sex );

Please log in or register to answer this question.

Position:
Show:

Related questions

0 0 votes
1 answers 1 answer
1.1k
1.1k views
Prince Sindhiya asked Sep 12, 2018
1,105 views
Consider the entity type DEPENDENT, related to EMPLOYEE, which is used to keeptrack of the dependents of each employee via a 1:N relationship,(assume dependent is weak en...
3 3 votes
4 4 answers
16.5k
16.5k views
Turning Turing asked Sep 25, 2016
16,533 views
Consider a universal relation R={ABCDEFGHIJ} and set of functional dependencies G = { {A,B} - {C} , {B,D}->{E,F} ,{A,D} ->{G,H} , {A} - {I} ,{H} - {J} } .a) What is the...
0 0 votes
1 1 answer
1.9k
1.9k views
ibia asked Apr 7, 2016
1,949 views
Specify the following queries in SQL on the database schema of Figure 1.2.Figure 1.2:A database that storesstudent and courseinformation.CaptionRetrieve the names of all ...
0 0 votes
0 0 answers
4.1k
4.1k views
ibia asked Apr 6, 2016
4,077 views
Specify the following queries in SQL on the COMPANY relational database schema shown in figure 3.5 .Show the result of each query if it is applied to the COMPANY databas...