|
|
|
(With the JOIN operator, the SQL query will look a lot like a Relational Algebra query.)
|
Relational Algebra query:
πfname, lname ( σdname='Research' ( Employee ⋈dno=dnumber Department ) ) |
select fname, lname from employee join department on dno=dnumber where dname='Research' |
Comment:
|
select ssn, fname, lname, essn, pno from employee join works_on on ssn=essn 123456789 John Smith 123456789 1 123456789 John Smith 123456789 2 333445555 Frank Wong 333445555 2 333445555 Frank Wong 333445555 3 333445555 Frank Wong 333445555 10 333445555 Frank Wong 333445555 20 999887777 Alice Miller 999887777 30 999887777 Alice Miller 999887777 10 987654321 Jack Wallace 987654321 30 987654321 Jack Wallace 987654321 20 666884444 John Doe 666884444 3 453453453 Joyce English 453453453 1 453453453 Joyce English 453453453 2 987987987 Jake Jones 987987987 30 987987987 Jake Jones 987987987 10 888665555 James Borg 888665555 20 |
select ssn, fname, lname, essn, pno, pnumber, pname from (employee join works_on on ssn=essn) join project on pno=pnumber SSN FNAME LNAME ESSN PNO PNUMBER PNAME --------- ---------- ---------- --------- ---------- ---------- --------------- 123456789 John Smith 123456789 2 2 ProductY 123456789 John Smith 123456789 1 1 ProductX 333445555 Frank Wong 333445555 20 20 Reorganization 333445555 Frank Wong 333445555 10 10 Computerization 333445555 Frank Wong 333445555 3 3 ProductZ 333445555 Frank Wong 333445555 2 2 ProductY 999887777 Alice Miller 999887777 10 10 Computerization 999887777 Alice Miller 999887777 30 30 Newbenefits 987654321 Jack Wallace 987654321 20 20 Reorganization 987654321 Jack Wallace 987654321 30 30 Newbenefits 666884444 John Doe 666884444 3 3 ProductZ 453453453 Joyce English 453453453 2 2 ProductY 453453453 Joyce English 453453453 1 1 ProductX 987987987 Jake Jones 987987987 10 10 Computerization 987987987 Jake Jones 987987987 30 30 Newbenefits 888665555 James Borg 888665555 20 20 Reorganization |
r1 INNER JOIN r2 ON join-condition |
The effect is the same as JOIN operator (see above).
|
select fname, lname from employee inner join department on dno=dnumber where dname='Research' |