SQLite INTERSECT operator

The SQLite INTERSECT operator is used to compare quried return data from two queries, returning only those distinct rows that are contained by both queries. Applying the SQLite INTERSECT operator requires that the return data of both the left and right query have the same amount of columns, in similar order and of some datatypes.

Exemplary syntax:

SELECT col1
FROM table1
INTERSECT
SELECT col2
FROM table2;

Here is an example:

CREATE TABLE table1(
    col1 INT
);

INSERT INTO table1(col1)
VALUES(1),(2),(3);

CREATE TABLE table2(
    col2 INT
);

INSERT INTO table2(col2)
VALUES(2),(3),(4);

This will return 2 and 3.