I am trying to extract email addresses from given list, that not persists in MySql database. My query:
SELECT *
FROM users
WHERE `user_email` IN ('myemail@email.com', 'my2email@email.com', 'my3email@email.com')
First two email addresses are in database, but the last one is not. My target is to print only emails that are NOT in database. How is that possible?
SELECT *
FROM (SELECT 'myemail@email.com' user_email
UNION ALL
SELECT 'my2email@email.com'
UNION ALL
SELECT 'my3email@email.com') emails_to_check_for
LEFT JOIN users USING (user_email)
WHERE users.user_email IS NULL;
create a temporary table and insert all the email ids that you want to check
create table check_emailid(email_id varchar(255))
insert into check_emailid(email_id )
values('myemail@email.com')
values('my2email@email.com')
values('my3email@email.com')
select *
from check_emailid
where email_id not in (SELECT user_email
FROM users)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.