Suppose there are tables A and B. A has name, surname fields, as well as B. How to display all name and surname in one table from A and B , except for those that both tables have.
Example: A {1,2,3}, B {5,1,7}, the result of R must be {2,3,5,7} (that is, except one) You should use such operators like EXCEPT, UNION ... .

    1 answer 1

    select coalesce(A.name,B.name) as name, coalesce(A.surname,B.surname) as surname from A full join B on A.name=B.name and A.surname=B.surname where (A.name is null and A.surname is null) or (B.name is null and B.surname is null) 

    As a hint on the use of EXCEPT and UNION, the general form of the query is select * from (A except B) X union all select * from (B except A) Y But I would say that this approach should not be used because instead of one connection, two except first are used, each of which is the same complexity as the union, and then also the union. plus double scan of both tables.