This code finds all records that campaign appears in both tables, then just shows one of each.
Table 1: – Blue, Red, Green, Red, Red
Table 2: – Blue, Red, Blue
Output: – Blue, Red (They appeared in both tables)
$query = "SELECT DISTINCT(campaign), client FROM table1 WHERE campaign NOT IN (SELECT campaign from targets where targets.campaign = cmdata.campaign)";