mysql - Multiple union statements and difference of resulting tables -


i trying construct query of following nature: if x in union of , b, not in union of c , d, return x.

for example:

table    table    table    table +---+    +---+    +---+    +---+ | |    | b |    | c |    | d | +---+    +---+    +---+    +---+ | 1 |    | 4 |    | 2 |    | 3 | | 2 |    | 5 |    | 3 |    | 7 | | 3 |    | 6 |    +---+    +---+ | 4 |    | 7 | +---+    +---+ 

i looking return:

+---+ | e | +---+ | 1 | | 4 | | 5 | | 6 | +---+ 

i've tried:

select * union select * b * not in (select * c union select * d) 

but think syntax incorrect. advice on how solve hugely appreciated.

i write query way:

select * a.id not in (select id c)       , a.id not in (select id d) union select * b b.id not in (select id c)       , b.id not in (select id d) 

you can write this:

select *   (select * union select * b) s   id not in (select id c union select id d) 

please see fiddle here. might want use union instead of union remove duplicates.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -