Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 14th, 2003, 09:22 AM
zeeshanakhund zeeshanakhund is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: PK
Posts: 57 zeeshanakhund User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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,,,

Reply With Quote
  #2  
Old October 14th, 2003, 09:35 AM
metaBarf metaBarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 373 metaBarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 49 m 6 sec
Reputation Power: 10
you need something to join them.

Reply With Quote
  #3  
Old October 14th, 2003, 09:52 AM
metaBarf metaBarf is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 373 metaBarf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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;

Reply With Quote
  #4  
Old October 14th, 2003, 10:13 AM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 2,351 swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level)swampBoogie User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 4 Days 8 h 1 m 50 sec
Reputation Power: 390
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 

Reply With Quote
  #5  
Old October 14th, 2003, 11:14 AM
Dan Drillich Dan Drillich is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 68 Dan Drillich User rank is Just a Lowly Private (1 - 20 Reputation Level) 
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > select records from multiple tables

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap