inner join - Mysql query where not exists -
i have 3 different tables - subscribers, unsubscribers, mass subscribers.
i'd print out each email mass subscribers table. email can printed if doesn't exist in both subscribers , unsubscribers tables.
i know how arrays, want plain mysql query.
what mysql query be?
thanks!
you can subquery (this slow! please read below line):
select email subscribers email not in(select email unsubscribers)
however, bad performance. suggest change way have database, 1 table subscribers
, , add column active
(tinyint). when unsubscribes, set value 1 0. after can stay in 1 table:
select email subscribers active=1
this faster because of reasons:
- no subquery
- the bad, because going select heap of data, , compare strings
- selecting on integer in fast (especially when index it)
apart fact faster, better database structure. dont want 2 tables doing same, emailadresses. create duplicate data , chance misalignments
Comments
Post a Comment