Follow us: Connect on YouTube Connect on YouTube Connect on YouTube

Pages

Thursday, 23 November 2017

Oracle SQL INTERSECT Set Operator


INTERSECT Operator

Use the INTERSECT operator to return all rows common to multiple queries.


SQL INTERSECT Operator
Guidelines
         The number of columns and the datatypes of the columns being selected by the SELECT statements in the queries must be identical in all the SELECT statements used in the query. The names of the columns need not be identical.
         Reversing the order of the intersected tables does not alter the result.
         INTERSECT does not ignore NULL values.
 

Using the INTERSECT Operator 

The INTERSECT operator returns common records from student tables srno102 record. 

Take examples from Student1 and Student2 tables 
 
Select * from Student1;



SrNo
Name
101
Name101
102
Name102
 


Select * from Student2;
 


SrNo
Name
102
Name102
103
Name103
 

Consider the following example:

SQL>SELECT * FROM student1
          INTERSECT
          SELECT * FROM student2;
         
Output:


SrNo
Name
102
Name102



 
SET Operator Guidelines

         The expressions in the SELECT lists must match in number and data type.
         Parentheses can be used to alter the sequence of execution.
         The ORDER BY clause:
        Can appear only at the very end of the statement
        Will accept the column name, aliases from the first SELECT statement, or the positional notation

 
You May Like:


Share this article :

0 comments:

Post a Comment