|
- CREATE TABLE tabla1 (
- id INT PRIMARY KEY
- );
-
- CREATE TABLE tabla2 (
- id INT PRIMARY KEY
- );
-
-
- INSERT INTO tabla1(id) VALUES(1),(2),(3);
-
- INSERT INTO tabla2(id) VALUES(2),(3),(4);
-
- #union
- select id from tabla1
- union
- select id from tabla2
-
- #intersec
- select id from tabla1
- where id in (select id from tabla2)
-
- #except
- select id from tabla1
- where id not in (select id from tabla2)
|