INTERSECT Operator

The INTERSECT operator returns only the rows that are present in both result sets of two SELECT queries.

Example: Using INTERSECT

SELECT Name FROM FreedomFighters WHERE City = 'Chennai'
INTERSECT
SELECT Name FROM FreedomFighters WHERE Contribution = 'Healthcare';

Output:

Returns names of freedom fighters who are from Chennai and also contributed to healthcare.

Notes

  • Both queries must return the same number of columns.
  • Data types of corresponding columns must be compatible.