Tuesday, February 21, 2012

Returning Matching/Non matching Records

Hi All

I have a strange request that might not be possible based on the laws of relational databases but I thought I'd give it a try.

I have three tables which for simplicity I will call A, B and C. Table A contains my master records, Table B contains user details and the final table contains some extra data

In my initial search when joining A and B, I return 100 records. I then need to search in table C for these 100 records based on a criteria. the expected result should return all 100 rows for the ones that match and also the ones that do not match. The problem is that in Table C, not all the 100 IDs exist, so there will not be a corresponding record. Unfortunately, our users still want to see all 100 records in the output. Is this possible

As always any help or direction would be appreciated.read brett's sticky...

ddl? sample data? do you have some code already?|||Is this possibleyou betcha!!

hint: A inner join B left outer join C|||it's possible, study more on the left join right join and inner join :)|||Thanks for the responses guys. I was actually doing this on behalf of a friend who I was awaiting some ddl from. He now reports that he's been able to resolve his issue. Thanks.|||Someone correct my method please...

I would have created 2 queries - one with IN and the other using a NOT IN criteria...

then unioned them...

If you get me

No comments:

Post a Comment