Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2009-08-25 : 00:15:38
|
| I'm going to try to keep this as general as possible as it is very confusing to explain.Is there a general syntax where you can compare the results of the product of 2 "IN" clauses?I'd like to return results where some of the results from one "IN" clause are in the results of another "IN" clause. But I only want to see results where all the results in subset B are in subset B.EX:Select ID, Column From Table Where Column in ('Cat', 'Dog', 'Frog')Subset AResults:ID Column1 Cat2 Dog3 FrogSelect ID, Column From Table Where Column in ('Cat', 'Dog', 'Frog')Subset BResults:ID Column11 Cat11 Dog Desired results:11 Cat11 DogImportant note, if another value ('lion' for example) were present in subset B, I would have wanted to exclude it.Also, the table that I'm working with is the same in both examples. There is a boolean column that differentiates between the two results though. There is no parent/child or source id.Thanks! |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-08-25 : 01:19:54
|
| select t.id,t.columnfrom (Select ID, Column From Table Where Column in ('Cat', 'Dog', 'Frog')) t inner join (Select ID, Column From Table Where Column in ('Cat', 'Dog', 'Frog'))s on s.column = t.column |
 |
|
|
flamblaster
Constraint Violating Yak Guru
384 Posts |
Posted - 2009-08-25 : 20:10:11
|
| Hi bklr...is there anyway to do this without putting the values in? Also, I don't want to see results where "Cat"occurs once but not "Dog". Both "Cat"and "dog" have to occur in TableB at least once because they happened once in Table A. |
 |
|
|
|
|
|
|
|