Monday, February 8, 2010

SQL EXISTS - Introduction and syntax

Explain the SQL EXISTS statement. Write SQL syntax for the SQL EXISTS statement along with an example.

SQL EXISTS: If the subquery returns at least one row the EXISTS condition is considered "to be met".

Syntax:
SELECT columns FROM tables WHERE EXISTS ( subquery );

Example:
SELECT * FROM employee WHERE EXISTS (select * from appraisal where employee.employee_id = appraisal.employee_id);

No comments:

Post a Comment