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:
  #1  
Old September 26th, 2004, 01:49 AM
MCannon MCannon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 MCannon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help pulling data through a join condition

Howdy folks I've been having one heck of a time trying to pull information from a table using join conditions. Here is my current code:

SELECT DISTINCT tbl_customer.last_name || ', '|| -tbl_customer.first_Name AS Name,
From tbl_customer,
tbl_order,
tbl_order_line,
tbl_Item
Where tbl_customer.customer_id = tbl_order.customer_id
AND tbl_Order_line.order_id = tbl_order.order_id
AND tbl_order_line.item_id = tbl_item.item_id;

What I need to do is print the customers name only for people that have purchased a game that sounds like "Knowledge Management" or "Managing Change".

The Customers name is located in the tbl_customer and the game name is located in the tbl_item.

What I can't wrap my mind around is how I can pull information from the last table and print it in my select statement. Thanks guys for your help! This has been driving me crazy...

Matt

Reply With Quote
  #2  
Old September 26th, 2004, 09:35 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 6
look at the following code, modification is marked by red color.

SELECT DISTINCT tbl_customer.last_name || ', '|| -tbl_customer.first_Name AS Name,
From tbl_customer,
tbl_order,
tbl_order_line,
-- tbl_Item [remove this table name from here]
Where tbl_customer.customer_id = tbl_order.customer_id
AND tbl_Order_line.order_id = tbl_order.order_id
AND tbl_order_line.item_id IN
(select item_id from tbl_Item
where item_name = soundex('Knowledge Management')
or item_name = soundex('Managing Change'))

/

or may be you mean exactly the same item name, look at the following query:


SELECT DISTINCT tbl_customer.last_name || ', '|| -tbl_customer.first_Name AS Name,
From tbl_customer,
tbl_order,
tbl_order_line,
-- tbl_Item [remove this table name from here]
Where tbl_customer.customer_id = tbl_order.customer_id
AND tbl_Order_line.order_id = tbl_order.order_id
AND tbl_order_line.item_id IN
(select item_id from tbl_Item
where item_name = 'Knowledge Management'
or item_name = 'Managing Change')
/

Reply With Quote
  #3  
Old September 27th, 2004, 12:27 PM
MCannon MCannon is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 4 MCannon User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks Shafique!

Solved the problem perfectly! Here is the final code...

SELECT DISTINCT tbl_customer.last_name||', '||tbl_customer.first_name Customer
From tbl_customer,
tbl_order,
tbl_order_line,
tbl_item
Where tbl_customer.customer_id = tbl_order.customer_id
AND tbl_Order_line.order_id = tbl_order.order_id
AND tbl_item.item_id = tbl_order_line.item_id
AND tbl_order_line.item_id IN
(select item_id from tbl_Item
where SOUNDEX(tbl_item.name) = SOUNDEX('Knowledge Management')
or SOUNDEX(tbl_item.name) = SOUNDEX('Managing Change'));

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Help pulling data through a join condition


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 6 hosted by Hostway
Stay green...Green IT