2007-04-14 01:49:11 +04:00
|
|
|
Syntax:
|
|
|
|
<code>
|
2007-04-14 03:33:37 +04:00
|
|
|
<operand> [NOT ]EXISTS (<subquery>)
|
2007-04-14 01:49:11 +04:00
|
|
|
</code>
|
|
|
|
The EXISTS operator returns TRUE if the subquery returns one or more rows and FALSE otherwise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The NOT EXISTS operator returns TRUE if the subquery returns 0 rows and FALSE otherwise.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Finding all articles which have readers:
|
|
|
|
<code>
|
|
|
|
FROM Article
|
|
|
|
WHERE EXISTS (FROM ReaderLog(id)
|
|
|
|
WHERE ReaderLog.article_id = Article.id)
|
|
|
|
</code>
|
|
|
|
Finding all articles which don't have readers:
|
|
|
|
<code>
|
|
|
|
FROM Article
|
|
|
|
WHERE NOT EXISTS (FROM ReaderLog(id)
|
|
|
|
WHERE ReaderLog.article_id = Article.id)
|
|
|
|
</code>
|
2007-04-13 00:52:30 +04:00
|
|
|
|