Tuesday, January 20, 2009

EXISTS Function From SQL

This following Query Explains, How to use Exists in SQL Query.

Have a look at the sample given below

USE pubs


SELECT au_lname, au_fname FROM authors

WHERE exists

(SELECT * FROM publishers WHERE authors.city = publishers.city)


When a subquery is introduced with the keyword EXISTS, it functions as an existence test. The WHERE clause of the outer query tests for the existence of rows returned by the subquery. The subquery does not actually produce any data; it returns a value of TRUE or FALSE.

No comments:

Post a Comment