select fname,lname,salary from employee where exists
(select essn from dependent where employee.sex = dependent.sex);
this is the query
select fname,lname,salary from employee where exists
(select essn from dependent where employee.sex = dependent.sex);
this is the query
Nicer SQL, avoiding exists
:
select distinct fname,lname,salary from employee
join dependent on employee.sex = dependent.sex;
Nicer nicer SQL, but only works if sex
is the only column in common between tables employee, dependent
select distinct fname,lname,salary from employee
natural join dependent;
Relational Algebra Appendix A style (with the same proviso)
(employee JOIN dependent) {fname,lname,salary}
Relational Algebra Codd 1972 style (with the same proviso)
π<fname,lname,salary>(employee ⋈ dependent)
< >
, because subscripting doesn't work in SO's code.)