Summary: in this tutorial, you will learn how to use the SQLite
Introduction to SQLite
INTERSECT operator compares the result sets of two queries and returns distinct rows that are output by both queries.
The following illustrates the syntax of the
The basic rules for combining the result sets of two queries are as follows:
- First, the number and the order of the columns in all queries must be the same.
- Second, the data types must be comparable.
CREATE TABLE t1(
INSERT INTO t1(v1)
CREATE TABLE t2(
INSERT INTO t2(v2)
The following statement illustrates how to use the
INTERSECT operator to compare result sets of two queries:
Here is the output:
The following picture illustrates the
For the demonstration, we will use the
invoices tables from the sample database.
The following statement finds customers who have invoices:
ORDER BY CustomerId;
The following picture shows the partial output:
In this tutorial, you have learned how to use the SQLite
INTERSECT operator to compare two queries and return distinct rows that are output by both queries.