rewards the products qualify for

Posted by Rod on Stack Overflow See other posts from Stack Overflow or by Rod
Published on 2012-10-07T02:34:02Z Indexed on 2012/10/07 3:38 UTC
Read the original article Hit count: 134

Filed under:
|
|
products purchased
--------------------------
bana
bana
bana
stra
kiwi

reward requirements table (related to a rewards table)
reward id, products
----------------------
1,bana
1,bana
1,bana
2,stra
2,bana
3,stra
4,cart
5,bana
5,bana
5,oliv

Can you help me with sql to get rewards the products purchased qualifies for?

In the case above the reward ids would be:

1
2
3

If there is a better design that would make the solution easier I welcome those as well. I'm using product names for the sake of easier explaining, I hope. (I'll replace with product ids later)

© Stack Overflow or respective owner

Related posts about sql

Related posts about sql-server