Exists Operator in oracle helps to result in a boolean value. Exists Operator in oracle use EXISTS Keyword for execution. A subquery with Exists Operator completes its functioning. Exists Operator returns true as soon as the subquery returns 1 row.
Follow the syntax for the Exists Operator below:
Syntax
Select column from Table_name
where Exists (subquery)...
Example
There is a table Stu as shown below:
Now, for instance let's consider that we need to check of any entry with name Radha is present in the data base. Follow the code to solve above query with exists Operator:
Select * from Stu s
where Exists(select * from Stu where s.Roll_no=1)
Output
Note:
1) The subquery will be executed and returns the values in terms of True and false.
2)The main query is displayed as an output only If Subquery results in true.
3) If subquery results in false then no rows from main query will be displayed.
- Log in to post comments