The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Databases
> Oracle Development
|
select records from multiple tables
Discuss select records from multiple tables in the Oracle Development forum on Dev Shed. select records from multiple tables Oracle Development forum discussing administration, Oracle queries, and other Oracle-related topics. Oracle is known as one of the most robust multi-platform relational databases available.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

October 14th, 2003, 09:22 AM
|
|
Contributing User
|
|
Join Date: Feb 2003
Location: PK
Posts: 57
Time spent in forums: 1 h 9 m 47 sec
Reputation Power: 11
|
|
|
select records from multiple tables
Following are the two tables
employee
--------
emp_id
emp_name
salary
grade
------
grade
lowsal
highsal
I want to retrieve the grades of each emlpoyee,,, how is it possible,,, what would be the SQL Statements,,,
|

October 14th, 2003, 09:35 AM
|
|
Contributing User
|
|
Join Date: Jun 2003
Posts: 373
Time spent in forums: 3 h 49 m 6 sec
Reputation Power: 10
|
|
|
you need something to join them.
|

October 14th, 2003, 09:52 AM
|
|
Contributing User
|
|
Join Date: Jun 2003
Posts: 373
Time spent in forums: 3 h 49 m 6 sec
Reputation Power: 10
|
|
|
so...
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, 10:13 AM
|
|
Contributing User
|
|
Join Date: Jan 2003
Location: Paris Uppland
|
|
Code:
select emp_name,grade
from employee , grade
where salary between lowsal and higsal
The syntax for a natural join is
Code:
SELECT * FROM employee natural join grades
|

October 14th, 2003, 11:14 AM
|
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 68
Time spent in forums: < 1 sec
Reputation Power: 10
|
|
|
Hi zeeshanakhund,
Which database/version do you use?
If you use Oracle, the following query will give you the information:
select * from v$version
Cheers,
Dan
Last edited by Dan Drillich : October 14th, 2003 at 11:17 AM.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|