SQLite Intersect Operator
The SQLite INTERSECT operator returns the common or intersection of two or more datasets. If the row exists in both data sets, then that will be included in the INTERSECT results. So, if the record does not exist in one of the datasets then it is not going to be considered in the results.
- The functionality of the SQLite operator is the same as the intersection in mathematics.
- The number of expressions or columns must be the same in both tables.
- Even the data types must be the same for the expressions that we are going to fetch.
Syntax:
SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions]
INTERSECT
SELECT expression1, expression2, ... expression_n
FROM tables
[WHERE conditions];
Syntax Explanation: Multiple SELECT statements followed by the table names from which we are going to fetch the data, Where condition which is optional and here comes the INTERSECT operator applied on the datasets.
Visual Representation of Intersect Operator
Output:
Explanation: In the above image we can observe how the SQLite Intersect works. Here T1 and T2 are two tables and the intersect operator is used to retrieve the common rows.
SQLite Intersect Operator
SQLite is a server-less database engine written in C programming language. It is developed by D. Richard Hipp in the year 2000. The main moto for developing SQLite is escaping complex database engines like MYSQL. It has become one of the most popular database engines as we use it in Television, Mobile Phones, Web browsers, and many more. It is written simply so that it can be embedded into other applications. In this article, we will learn about the SQLite Except operator, how it works, and the functionality of it.