sql - Query selecting common part of selected records -


i have problem constructing simple query, complicated using count function comes mind.

here table:

id | | b -----------  1 | 1 | 1  2 | 1 | 2  3 | 1 | 3  4 | 1 | 4  5 | 2 | 1  6 | 2 | 2  7 | 2 | 5  8 | 2 | 6  9 | 3 | 1 10 | 3 | 3 11 | 3 | 7 

i need values b, exist in every selected a. example table = 1 , 2 output b = 1 , 2

my plan take b, in selected using function in. , using function count count every b , if equal number of selected right.

my second based on loop. use vba, first query find b a=1, b found in previous step find that, a=2 , on. complicated.

what's opinion that.

thank reply.

examples:

a in {1,2} => output: b = {1,2}, because b = 1 = 1 id = 1 , b = 1 = 2 id = 5 (similar way b = 2) b = 3 = 1 id = 3, not b id in {1, 2, 3} => output: b = {1}, in {1, 3} => output: b = {1, 3}, in {2, 3} => output: b = {1} 

select b.b  (select b tablex = val1) join (select b tablex = val2) b on a.b=b.b 

untested.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -