1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - Exists Expressions.php

26 lines
588 B
PHP
Raw Normal View History

2007-04-14 01:49:11 +04:00
Syntax:
<code>
<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>