I have the following MySQL query.
SELECT
login,
firstname,
lastname,
email
FROM
xcart_customers
WHERE
login LIKE 'anonymous%'
AND email NOT IN (
SELECT
email
FROM
xcart_customers AS cx
WHERE
cx.login NOT LIKE 'anonymous%'
)
GROUP BY
email;
Basically there are two sets of customers, customers that have logins, and anonymous customers who all start with a login of 'anonymous%'.
I am trying to remove non-anonymous users from the list, that have the same email address as the anonymous users.
I thought the above query would have worked, but I still get some emails addresses that match non-anonymous users.
login | firstname | lastname | email
---------------------------------------------------------------------------
anonymous-10 | Eric | Byorn | byorn@mail.com
---------------------------------------------------------------------------
some_user_name | Eric | Byorn | byorn@mail.com
---------------------------------------------------------------------------
So I am trying to solve, all anonymous users, who only appear in the anonymous results.