Oracle INTERSECT Operator:-
In Oracle, INTERSECT Operator is used to return the results of 2 or more SELECT statement. It picks the common or intersecting records from compound SELECT queries.
Syntax:-
Explanation:-
Example:- (With single expression)
Suppliers Table
Suppliers Data:-
Order_details Table:-
Order_details Data :-
Syntax:-
SELECT expression1, expression2, ... expression_n FROM table1 WHERE conditions INTERSECT SELECT expression1, expression2, ... expression_n FROM table2 WHERE conditions;
Explanation:-
- expression1, expression2, ... expression_n:- It specifies the columns that you want to retrieve.
- table1, table2:- It specifies the tables that you want to retrieve records from.
- conditions:- It specifies the conditions that must be fulfilled for the records to be selected.
Example:- (With single expression)
Suppliers Table
Suppliers Data:-
Order_details Table:-
Order_details Data :-
SELECT supplier_id FROM suppliers INTERSECT SELECT supplier_id FROM order_details;