new DQL docs
This commit is contained in:
parent
5957622575
commit
42f7cb706f
@ -0,0 +1,26 @@
|
||||
Syntax:
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
<i>operand</i> [NOT ]EXISTS (<i>subquery</i>)
|
||||
</pre>
|
||||
</div>
|
||||
The EXISTS operator returns TRUE if the subquery returns one or more rows and FALSE otherwise. <br \>
|
||||
<br \>
|
||||
The NOT EXISTS operator returns TRUE if the subquery returns 0 rows and FALSE otherwise.<br \>
|
||||
<br \>
|
||||
Finding all articles which have readers:
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM Article
|
||||
WHERE EXISTS (FROM ReaderLog(id)
|
||||
WHERE ReaderLog.article_id = Article.id)
|
||||
</pre>
|
||||
</div>
|
||||
Finding all articles which don't have readers:
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM Article
|
||||
WHERE NOT EXISTS (FROM ReaderLog(id)
|
||||
WHERE ReaderLog.article_id = Article.id)
|
||||
</pre>
|
||||
</div>
|
@ -1,13 +1,15 @@
|
||||
Syntax:
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
<i>operand</i> IN (<i>subquery</i>|<i>valuelist</i>)
|
||||
<i>operand</i> IN (<i>subquery</i>|<i>value list</i>)
|
||||
</pre>
|
||||
</div>
|
||||
An IN conditional expression returns true if the <i>operand</i> is found from result of the <i>subquery</i>
|
||||
or if its in the specificied comma separated <i>valuelist</i>, hence the IN expression is always false if the result of the subquery
|
||||
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
|
||||
is empty.
|
||||
|
||||
When <i>value list</i> is being used there must be at least one element in that list.
|
||||
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM C1 WHERE C1.col1 IN (FROM C2(col1));
|
||||
|
@ -0,0 +1,50 @@
|
||||
<b>Strings</b><br \>
|
||||
|
||||
A string literal is enclosed in single quotes—for example: 'literal'. A string literal that includes a single
|
||||
quote is represented by two single quotes—for example: 'literal''s'.
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM User WHERE User.name = 'Vincent'
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<b>Integers</b><br \>
|
||||
Integer literals support the use of PHP integer literal syntax.
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM User WHERE User.id = 4
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<b>Floats</b><br \>
|
||||
Float literals support the use of PHP float literal syntax.
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM Account WHERE Account.amount = 432.123
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<br \>
|
||||
<b>Booleans</b><br \>
|
||||
The boolean literals are true and false.
|
||||
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM User WHERE User.admin = true
|
||||
|
||||
FROM Session WHERE Session.is_authed = false
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<br \>
|
||||
<b>Enums</b><br \>
|
||||
The enumerated values work in the same way as string literals.
|
||||
|
||||
<div class='sql'>
|
||||
<pre>
|
||||
FROM User WHERE User.type = 'admin'
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
<br \>
|
||||
Predefined reserved literals are case insensitive, although its a good standard to write them in uppercase.
|
@ -0,0 +1,11 @@
|
||||
A subquery can contain any of the keywords or clauses that an ordinary SELECT query can contain.
|
||||
<br \><br \>
|
||||
Some advantages of the subqueries:
|
||||
<ul>
|
||||
<li \>They allow queries that are structured so that it is possible to isolate each part of a statement.
|
||||
|
||||
<li \>They provide alternative ways to perform operations that would otherwise require complex joins and unions.
|
||||
|
||||
<li \>They are, in many people's opinion, readable. Indeed, it was the innovation of subqueries that gave people the original idea of calling the early SQL “Structured Query Language.”
|
||||
|
||||
</ul>
|
Loading…
x
Reference in New Issue
Block a user