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 11th, 2011, 01:01 PM
Coldweather Coldweather is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2007
Location: Sweden
Posts: 48 Coldweather User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 h 30 m 28 sec
Reputation Power: 7
Oracle SQL laboration help (school coure) Subquery and Join

Hi,

I have a introductory course in database systems (Oracle SQL) at my university and now when we have moved on to nested querys and joins I would very much appreciate some pointers form anyone who have spare time.

In this lab I am supposed to display customer number, first name and last name of all customers that have ordered items from item group clothes or item group magazines. I have solved the lab using nested querys (it works anyway), but I am stuck at solving it using the inner join.

Here is a diagram of the tables that we are to work with.


And here is my nested query solution, please do leave a comment if this way is "wrong". I have a vague memory that the lecturer said that every time we need to "hop" to another table, it will cause one more query?
Code:
select cnr, fname, lname
from customer
where cnr in(
    select distinct cnr
    from customerorder
    where ordnr in(
        select ordnr
        from orderrow
        where itemnr in(
            select itemnr
            from item
            where ignr in (
                select ignr
                from itemgroup
                where igname in('clothes','magazines')
            )
        )
    )
);


The output should look like this
Code:
CNR FNAME                ENAME
--- -------------------- ---------
  3 carl                smith
  4 eric                jonsson
  6 maria               brown


And if you know of a good Oracle PL/SQL book that is easy to grasp with good examples please leave a comment, I would like to complement the couse book (I find it to be more like a reference manual...).

Regards,
Marcus

Last edited by Coldweather : October 11th, 2011 at 01:26 PM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle SQL laboration help (school coure) Subquery and Join

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