I have the following table (it's a list of bannerids and available sizes for each):
bannerid, bannersize
--------------------
1, 16
1, 32
1, 128
2, 16
2, 32
2, 128
2, 256
2, 512
3, 16
3, 32
3, 64
3, 128
3, 256
3, 512
3, 1024
I need to be able to generate a list of all bannerid that have all the possible sizes (16, 32, 64, 128, 256, 512, 1024)
So in this example, the result should be:
bannerid
--------
3, 16
3, 32
3, 64
3, 128
3, 256
3, 512
3, 1024
Since bannerid 3 has all the possible sizes as mentioned above (1 and 2 were missing few sizes).
What's a good way to achieve this? I assume there's a better way than doing a join 7 times on the same table and checking that every possible size combination exists.
I also want a way to control which bannerid get displayed: (a) those matching all sizes, or (b) matching some sizes as I specify.