Assignment:-
Assign. Name:- In SQL Use of SET Operator.
CLASS:-T.Y.B.Sc(Computer)
*************************************************************
Use of SET Operator:
- UNION
- INTERSECT
- IN
- NOT IN
SQL>select * from borrower;
CUST_NAME LOAN_NO
--------------------- -------------
Samir 1
Mahesh 2
Smita 3
Vrushali 4
Devendra 5
Vaibhav 6
UNION:-
SQL> (select cust_name from borrower) UNION
(select cust_name from depositer);
CUST_NAME
-----------------------
Devendra
Mahesh
Samir
Smita
Vaibhav
Vrushali
6 rows selected.
SQL> (Select cust_name from borrower) UNION ALL
(Select cust_name from depositer);
CUST_NAME
---------------------------------
Samir
Mahesh
Smita
Vrushali
Devendra
Vaibhav
Samir
Mahesh
Samita
Vrushali
Devendra
11 row selected.
INTERSECT:-
SQL> (Select cust_name from borrower) INTERSECT
(Select cust_name from depositer);
CUST_NAME
----------------------------
Devendra
Mahesh
Samir
Smita
Vrushali
IN:-
SQL> Select DISTINCT cust_name from borrower WHERE
cust_name IN (Select cust_name from depositer);
CUST_NAME
------------------------
Devendra
Mahesh
Samir
Smita
Vrushali
NOT IN:-
SQL> Select DISTINCT cust_name from borrower WHERE
cust_name NOT IN (Select cust_name from depositer);
CUST_NAME
----------------------
Vaibhav
Use of SET Operator:
- UNION
- INTERSECT
- IN
- NOT IN
SQL>select * from borrower;
CUST_NAME LOAN_NO
--------------------- -------------
Samir 1
Mahesh 2
Smita 3
Vrushali 4
Devendra 5
Vaibhav 6
UNION:-
SQL> (select cust_name from borrower) UNION
(select cust_name from depositer);
CUST_NAME
-----------------------
Devendra
Mahesh
Samir
Smita
Vaibhav
Vrushali
6 rows selected.
SQL> (Select cust_name from borrower) UNION ALL
(Select cust_name from depositer);
CUST_NAME
---------------------------------
Samir
Mahesh
Smita
Vrushali
Devendra
Vaibhav
Samir
Mahesh
Samita
Vrushali
Devendra
11 row selected.
INTERSECT:-
SQL> (Select cust_name from borrower) INTERSECT
(Select cust_name from depositer);
CUST_NAME
----------------------------
Devendra
Mahesh
Samir
Smita
Vrushali
IN:-
SQL> Select DISTINCT cust_name from borrower WHERE
cust_name IN (Select cust_name from depositer);
CUST_NAME
------------------------
Devendra
Mahesh
Samir
Smita
Vrushali
NOT IN:-
SQL> Select DISTINCT cust_name from borrower WHERE
cust_name NOT IN (Select cust_name from depositer);
CUST_NAME
----------------------
Vaibhav