Jump to content

Have not purchased any of these products


The Little Guy

Recommended Posts

I need to get a list of all the members in a table that have not purchased these products: 14,42,29,86,43,9,44,12,45

 

I thought that this would work but doesn't:

select m.member_id from members m join purchases p on(m.member_id = p.member_id) where and level_id = 3 and is_active and p.product_id not in(14,42,29,86,43,9,44,12,45) group by member_id;

 

I can not figure this out, thanks for any help!

Link to comment
Share on other sites

Looks like I got it with this code:

 

select m.member_id from members m join purchases p on(m.member_id = p.member_id) where level_id = 3 and is_active and m.reg_date >= unix_timestamp('2010-01-01') and (
m.member_id not in(select member_id from purchases where product_id = 14) and
m.member_id not in(select member_id from purchases where product_id = 42) and
m.member_id not in(select member_id from purchases where product_id = 29) and
m.member_id not in(select member_id from purchases where product_id = 86) and
m.member_id not in(select member_id from purchases where product_id = 43) and
m.member_id not in(select member_id from purchases where product_id = 9) and
m.member_id not in(select member_id from purchases where product_id = 44) and
m.member_id not in(select member_id from purchases where product_id = 12) and
m.member_id not in(select member_id from purchases where product_id = 45)
) group by member_id;

Link to comment
Share on other sites

I need to get a list of all the members in a table that have not purchased these products: 14,42,29,86,43,9,44,12,45

 

I thought that this would work but doesn't:

select m.member_id from members m join purchases p on(m.member_id = p.member_id) where and level_id = 3 and is_active and p.product_id not in(14,42,29,86,43,9,44,12,45) group by member_id;

 

I can not figure this out, thanks for any help!

 

select m.member_id from members m join purchases p on(m.member_id = p.member_id AND p.product_id not IN (14,42,29,86,43,9,44,12,45)) where level_id = 3 and is_active group by member_id;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.