Connecting Tech Pros Worldwide Help | Site Map

Semi Join with 3 tables

Newbie
 
Join Date: Sep 2008
Location: India
Posts: 4
#1: Sep 12 '08
Hi,
i have 2 tables A & C but i dont have any column common to join them. so i am using a 2nd table say B from my data base and using that i am joing A and C.
I want only distinct Values from the table A. Column which is used for Joining A and B is havng multiple values in Table C.
can any1 suggest me how to perform semi join with 3 tables so i get ONLY distinct rows from table A.
query is being used for inserting data and a sequence is being used while inserting so i am not able to use "select distinct".here is my Joining condition.


Where EXISTS (
Select 1
from B
where
B.DISPATCH_NUMBER=A.DISP_NO
and
B.SERVICE_SKU like C.SKU_NUMBER||'%')
)
table C is having more then 1 SKU_number for the a DISPATCH_NUMBER of table B so i am getting multiple rows.Please do tell me how to resolve this issue.
amitpatel66's Avatar
Moderator
 
Join Date: Mar 2007
Location: Hyderabad, India
Posts: 2,192
#2: Sep 12 '08

re: Semi Join with 3 tables


Try this way:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT * FROM tablea A,(SELECT DISTINCT column3 FROM tablec) C WHERE EXISTS (SELECT 1 FROM B WHERE B.column1 = A.column1 AND 
  3. B.column2 LIKE C.column3||%);
  4.  
  5.  
Reply


Similar Oracle Database bytes