i have a table (inactive) like:
email (varchar 50), country, active? (2)
and another table (active) like:
email (varchar 50), country
i want to check if any of the addresses in email column at "active" is also in the "inactive" table and if so so it would update the "active?" column to: 0/1 or yes/no.
update test1
inner join test2
on test1.email = test2.email
set test1.active = 1
;
Try this solution using UPDATE LEFT JOIN:
UPDATE inactive i LEFT JOIN active a USING(email)
SET i.`active?` = 1
WHERE a.country IS NOT NULL
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.