Table:2018
No Email
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
Table:2017
No Email
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
Table:2016
No Email
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
Table:2019
No Email
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
I need to perform Union of tables 2018,2017,2016 without any duplicate emails minus table 2019 ,Result should look like
RESULT
No Email
1 [email protected]
2 [email protected]
3 [email protected]
4 [email protected]
5 [email protected]
6 [email protected]
7 [email protected]
Minus operation is not available in Mysql.
select a.*from(select *from y2018 union select *from y2017 where not exists(select *from y2018 where y2018.email=y2017.email ) union select *from y2016 where not exists(select *from y2018 where y2018.email=y2016.email ))a LEFT OUTER JOIN y2019 b on a.email=b.email where b.email is null ;
This gives the result but does not eliminate the duplicates in (2017 union 2016)
some one please help me