Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old April 12th, 2008, 12:35 PM
fm_001 fm_001 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 fm_001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 21 sec
Reputation Power: 0
Retrieving Data from 3 or more tables

Dear Friends,
I have recently joined and I have registered to forums for the first time, please don't be offended if I haven't posted in a proper manner.

I have a problem with my Oracle 9i SQL Query and I'm struggling to get it done.

I have three tables namely Student, Lease and Room and want to retrieve data from these three tables.

I want the Student name, the Lease details and the Room No from these tables.

The problem with my SQL query is that I get all the information from the tables except from the Room table, where in the column it show Room_No but the values are not displayed, the query is given below. Any help given to this query whether it works or not will be appreciated.

Code:

SELECT STUDENT.STU_FNAME, STUDENT.STU_LNAME, LEASE.LSE_NO, LEASE.LSE_DURATION, LEASE.LSE_STARTS, LEASE.LSE_ENDS, ROOM.ROOM_NO

FROM STUDENT

LEFT OUTER JOIN LEASE ON LEASE.STU_ID = STUDENT.STU_ID
LEFT OUTER JOIN ROOM ON ROOM.PLACE_NO = LEASE.PLACE_NO;


Thank You

Reply With Quote
  #2  
Old April 13th, 2008, 09:01 AM
vpire vpire is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2005
Posts: 150 vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level)vpire User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 6 h 56 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by fm_001
Dear Friends,
I have recently joined and I have registered to forums for the first time, please don't be offended if I haven't posted in a proper manner.

I have a problem with my Oracle 9i SQL Query and I'm struggling to get it done.

I have three tables namely Student, Lease and Room and want to retrieve data from these three tables.

I want the Student name, the Lease details and the Room No from these tables.

The problem with my SQL query is that I get all the information from the tables except from the Room table, where in the column it show Room_No but the values are not displayed, the query is given below. Any help given to this query whether it works or not will be appreciated.

Code:

SELECT STUDENT.STU_FNAME, STUDENT.STU_LNAME, LEASE.LSE_NO, LEASE.LSE_DURATION, LEASE.LSE_STARTS, LEASE.LSE_ENDS, ROOM.ROOM_NO

FROM STUDENT

LEFT OUTER JOIN LEASE ON LEASE.STU_ID = STUDENT.STU_ID
LEFT OUTER JOIN ROOM ON ROOM.PLACE_NO = LEASE.PLACE_NO;


Thank You


You can give this a try
Code:
SELECT S.STU_FNAME, S.STU_LNAME, L.LSE_NO, L.LSE_DURATION, L.LSE_STARTS, L.LSE_ENDS, R.ROOM_NO
FROM STUDENT S, LEASE L, ROOM R
WHERE S.STU_ID = L.STU_ID AND L.PLACE_NO = R.PLACE_NO;

Reply With Quote
  #3  
Old April 13th, 2008, 12:03 PM
fm_001 fm_001 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 fm_001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 21 sec
Reputation Power: 0
Doesn't Work

Quote:
Originally Posted by vpire
You can give this a try
Code:
SELECT S.STU_FNAME, S.STU_LNAME, L.LSE_NO, L.LSE_DURATION, L.LSE_STARTS, L.LSE_ENDS, R.ROOM_NO
FROM STUDENT S, LEASE L, ROOM R
WHERE S.STU_ID = L.STU_ID AND L.PLACE_NO = R.PLACE_NO;


I have tried this before but it displays now rows selected, I think there might be a problem with my table. Thank You for your help!

Reply With Quote
  #4  
Old April 14th, 2008, 04:42 AM
fm_001 fm_001 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 3 fm_001 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 43 m 21 sec
Reputation Power: 0
The code does work!!!

Thanks for your help, the code which you had send me did work, there was actually a spelling mistake in my table where the other table couldn't find a link with the primary key.

Once again thank you.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Retrieving Data from 3 or more tables


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway