SQL INTERSECT - Introduction and syntax
SQL - Dec 03, 2008 at 18:00 PM by Rajmeet Ghai
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;
WHERE: It is used to fetch records that fulfill a specified
condition.................
TOP clause is used to specify the number of records to return. Usually used for
large tables.................
We have CUBE or ROLLUP operators to generate summary reports. Both are part of
the GROUP BY clause of the SELECT statement.............
SQL MINUS returns all rows in the first query that are not returned in the
second query..................
LIKE clause is used for pattern matching. % is used to match any string of any
length where as _ allows you to match on a single character................
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..............
|