create database if not exists cviko2; use cviko2; -- drop table if exists drop table if exists T; drop table if exists T1; drop table if exists T2; -- create table create temporary table T(a int, b int); create temporary table T1(a int); create temporary table T2(a int, b int); -- insert insert T values (1,1), (1,2), (2,1); insert T1 values (1), (1), (2); insert T2 values (1,1), (1,2), (2,1); -- select SELECT * FROM T; SELECT * FROM T1; SELECT * FROM T2; -- join SELECT T1.a, T2.b FROM T1 JOIN T2 ON T2.a = T1.a; SELECT T1.a, T2.b FROM T1 JOIN T2 ON T2.a = T1.a EXCEPT ALL SELECT * FROM T;