In this chapter you will learn:
What is EXISTS clause?
Syntax of EXISTS clause
Example of EXISTS clause
What is EXISTS clause?
The EXISTS clause helps to check the existence of a subquery according to the condition specified and passes the status of existence to the outer query. It always returns a Boolean value (True or False).
Syntax of EXISTS clause
SELECT column_name from table_name where EXISTS (SELECT column_name from table_name where conditional_expression)
Example of EXISTS clause
select employeeid, title from humanresources.employee where exists (select * from humanresources.employeedepartmenthistory where employeeid=humanresources.employee.employeeid and departmentid=4)
SUMMARY
In this chapter, you have learned about EXISTS clause with an example. In the next chapter you will learn about BETWEEN clause.