intersection in sql code example
Example 1: what is intersect in sql
The SQL INTERSECT clause/operator is used to combine two SELECT statements,
but returns rows only from the first SELECT statement
that are identical to a row in the second SELECT statement.
This means INTERSECT returns only common rows returned by the two
SELECT statements.
Example 2: intersect sql
INTERSECT:
BASICALLY INTERSECT COMBINES COMMON
ELEMENTS OF BOTH TABLES
Example 3: intersection in sql
SELECT ID, NAME, Amount, Date
FROM Customers
LEFT JOIN Orders
ON Customers.ID = Orders.Customer_id
INTERSECT
SELECT ID, NAME, Amount, Date
FROM Customers
RIGHT JOIN Orders
ON Customers.ID = Orders.Customer_id;
Example 4: intersect sql
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]
INTERSECT
SELECT column1 [, column2 ]
FROM table1 [, table2 ]
[WHERE condition]