Monday, February 8, 2010

SQL INTERSECT - Introduction and syntax

Explain the SQL INTERSECT statement. Write SQL syntax for the SQL INTERSECT statement along with an example.

SQL INTERSECT allows combining results of two or more select queries. If a record exists in one query and not in the other, it will be omitted from the INTERSECT results.

Syntax:
Select field1, field2, . field_n from tables INTERSECT select field1, field2, . field_n from tables;

Example:
Select salary from employee INTERSECT select salary from manager;

No comments:

Post a Comment