Showing posts with label SQL Commands. Show all posts
Showing posts with label SQL Commands. Show all posts

INTERSECT clause in Oracle, SQL Server and MySQL

INTERSECT clause is used in oracle and SQL Server to retrieve the data which are exists in both the tables.i.e we can say common records present in both the tables.

Syntax:

select column1, column2,....
from table 1 [where clause]
intersect
select column1, column2 ... 
from table2 [where clause]

For example  Table1 and table2 as below

MINUS clause in Oracle, SQL Server and MySQL

Minus clause in oracle used to query the records which are exists in table1 but not in table2.

select * from table1

minus
select * from table 2

or


select column1, column2... from table1

minus
select column1, column2... from table2

Make sure the data types for the columns should be compatible.