Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SQL-Query-Question: get all ID2 which have specific ID1

$
0
0

Hello,

I have a table Tab1 with millions of entries like

ID1    ID2

1       aa
4       aa
1       bb
4       cc

I'm looking for a sql-query which gives me all ID2-values which have a all of the supplied ID1, in the example above if I query for 1 4 then I want aa and not bb or cc because bb has only 1 and cc only 4.

The values of ID1 could be a lot like (1,2,3,5,7,8,9,10,34,4,67,33,53,43...).

Greetings

Stefan


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>