|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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') / |
|
#3
|
|||
|
|||
|
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')); |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Help pulling data through a join condition |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|