Can you build a MySQL query to show not found results from the conditional -
i trying find out how find emails not exist in table using emails conditional.
i create table these emails seems overkill need for. looking query show me conditional value , null user id.
is possible?
i have query this:
select u.uid, u.mail `users` u u.mail in ( 'alot@of', 'emails@that', 'ineed@tofind', )
this works great @ finding emails , associating user id. need identify emails not exist in result. using 56 emails , 6 not appear in list. trying identify emails not found.
not in
won't work have on 40,000 users. want identify emails not found conditional. have 56 emails , 50 results. need identify 6 not found (they may not in table @ all)
let me effort clarify little more: given list of emails supposed accounts in system. trying find accounts given email. part fine. now, issue having, given 56 emails 50 found. need identify emails out of 56 not found. emails thrown conditional. not in
won't work because homecoming user 50 found. (roughly 40,000) need identify emails conditional not found in table.
thanks insight or suggestions need.
as posted in comments, not in
may helpful. there other ways. 1 of them left bring together table result of query , show non-coincident rows:
select u.uid, u.mail users u left bring together ( select u.uid, u.mail users mail service in ('alot@of','emails@that','ineed@tofind') ) on u.uid = a.uid a.uid null;
add fields need bring together (if uid
not enough)
so question becomes more complicated... want find e-mails in condition not found in table.
as far know, there's not simple sql sentence give that... can work temp tables , it. solution implies:
create temporary table hold values want search (and add together appropriate indexes it) insert values want search executeselect
query find non-matching rows so... let's it:
-- 1. create temp table hold values drop table if exists temp_search_values; create temporary table temp_search_values ( mail service varchar(100), unique index idx_mail(mail) -- don't allow duplicate values here ); -- 2. insert search values insert temp_search_values (mail) values ('alot@of'),('emails@that'),('ineed@tofind'); -- 3. execute query select a.* users u left bring together temp_search_values on u.mail = a.mail u.mail null;
remember: temporary tables visible connection created them, , deleted when connection closed or killed.
mysql
No comments:
Post a Comment