October 14th, 2003, 10:22 AM
select records from multiple tables
Following are the two tables
I want to retrieve the grades of each emlpoyee,,, how is it possible,,, what would be the SQL Statements,,,
October 14th, 2003, 10:35 AM
you need something to join them.
October 14th, 2003, 10:52 AM
SELECT grades.employee_id, grades.grade, grades.high, grades.low
FROM employee, grades
WHERE employee.employee_id = grade.employee_id;
here you would have had to add the employee_id attribute to grade relation. I forget about if you can use other join syntax in oracle, it's been a while. You can usually do it with NATURAL JOIN in this situation
SELECT * FROM employee, grades WHERE employee NATURAL JOIN grades;
October 14th, 2003, 11:13 AM
The syntax for a natural join is
from employee , grade
where salary between lowsal and higsal
SELECT * FROM employee natural join grades
October 14th, 2003, 12:14 PM
Which database/version do you use?
If you use Oracle, the following query will give you the information:
select * from v$version
Last edited by Dan Drillich; October 14th, 2003 at 12:17 PM.