Can anyone explain intersect in SQL?

0 votes

In SQL, the INTERSECT operator is used to returns the common rows of result sets of two SELECT statements. It has the same rules as UNION operator that the result sets of both SELECT statements must have the same number of columns, similar data types of columns, and the order also should be same.

Here is the syntax for using INTERSECT operator in SQL:

SELECT column_list

FROM TableA

WHERE condition

INTERSECT

SELECT column_list

FROM TableB

WHERE condition;

You can check out this SQL Tutorial blog by Intellipaat to learn more about INTERSECT operator and other operators.