469,345 Members | 5,900 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,345 developers. It's quick & easy.

Semi Join with 3 tables

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.
Sep 12 '08 #1
1 3476
amitpatel66
2,367 Expert 2GB
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.  
Sep 12 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Andrey Krivda 232973226 | last post: by
4 posts views Thread by Anthony Robinson | last post: by
2 posts views Thread by dskillingstad | last post: by
7 posts views Thread by Shanimal | last post: by
3 posts views Thread by Zeff | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.