1
0
mirror of synced 2024-12-14 15:16:04 +03:00
doctrine2/manual/docs/DQL (Doctrine Query Language) - Conditional expressions - In expressions.php

29 lines
792 B
PHP
Raw Normal View History

2006-10-10 21:33:26 +04:00
Syntax:
<div class='sql'>
<pre>
2006-10-11 00:52:10 +04:00
<i>operand</i> IN (<i>subquery</i>|<i>value list</i>)
2006-10-10 21:33:26 +04:00
</pre>
</div>
An IN conditional expression returns true if the <i>operand</i> is found from result of the <i>subquery</i>
2006-10-11 00:52:10 +04:00
or if its in the specificied comma separated <i>value list</i>, hence the IN expression is always false if the result of the subquery
2006-10-10 21:33:26 +04:00
is empty.
2006-10-11 00:52:10 +04:00
When <i>value list</i> is being used there must be at least one element in that list.
2006-10-10 21:33:26 +04:00
<div class='sql'>
<pre>
FROM C1 WHERE C1.col1 IN (FROM C2(col1));
FROM User WHERE User.id IN (1,3,4,5)
</pre>
</div>
The keyword IN is an alias for = ANY. Thus, these two statements are equal:
<div class='sql'>
<pre>
FROM C1 WHERE C1.col1 = ANY (FROM C2(col1));
FROM C1 WHERE C1.col1 IN (FROM C2(col1));
</pre>
</div>