in Databases
655 views
1 vote
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 );
in Databases
655 views

4 Comments

both queries are co-related queries only
0
0
Yes both are correlated but i am saying that first one is more efficient then second one
0
0

no.... those are equivalent

it may help https://gateoverflow.in/257092

0
0

Please log in or register to answer this question.

Related questions