FROM <i>component_reference</i> [[LEFT | INNER] JOIN <i>component_reference</i>] ...
</pre>
</div>
The FROM clause indicates the component or components from which to retrieve records.
If you name more than one component, you are performing a join.
For each table specified, you can optionally specify an alias.
<br \><br \>
<li \> The default join type is <i>LEFT JOIN</i>. This join can be indicated by the use of either 'LEFTJOIN' clause or simply ',', hence the following queries are equal:
<div class='sql'>
<pre>
SELECT u.*, p.* FROM User u LEFT JOIN u.Phonenumber
SELECT u.*, p.* FROM User u, u.Phonenumber p
</pre>
</div>
<li \><i>INNER JOIN</i> produces a Cartesian product between two specified components (that is, each and every record in the first component is joined to each and every record in the second component).
So basically <i>INNER JOIN</i> can be used when you want to efficiently fetch for example all users which have one or more phonenumbers.
In order to sort in reverse order you can add the DESC (descending) keyword to the name of the column in the ORDER BY clause that you are sorting by. The default is ascending order; this can be specified explicitly using the ASC keyword.
The SELECT statement is used for the retrieval of data from one or more components.
<ul>
<li \>Each <i>select_expr</i> indicates a column or an aggregate function value that you want to retrieve. There must be at least one <i>select_expr</i> in every SELECT statement.
<div class='sql'>
<pre>
SELECT a.name, a.amount FROM Account a
</pre>
</div>
<li \>An asterisk can be used for selecting all columns from given component. Even when using an asterisk the executed sql queries never actually use it
(Doctrine converts asterisk to appropriate column names, hence leading to better performance on some databases).
<div class='sql'>
<pre>
SELECT a.* FROM Account a
</pre>
</div>
<li \>FROM clause <i>components</i> indicates the component or components from which to retrieve records.
<div class='sql'>
<pre>
SELECT a.* FROM Account a
SELECT u.*, p.*, g.* FROM User u LEFT JOIN u.Phonenumber p LEFT JOIN u.Group g
</pre>
</div>
<li \>The WHERE clause, if given, indicates the condition or conditions that the records must satisfy to be selected. <i>where_condition</i> is an expression that evaluates to true for each row to be selected. The statement selects all rows if there is no WHERE clause.
<div class='sql'>
<pre>
SELECT a.* FROM Account a WHERE a.amount > 2000
</pre>
</div>
<li \>In the WHERE clause, you can use any of the functions and operators that DQL supports, except for aggregate (summary) functions
<li \>The HAVING clause can be used for narrowing the results with aggregate functions
<div class='sql'>
<pre>
SELECT u.* FROM User u LEFT JOIN u.Phonenumber p HAVING COUNT(p.id) > 3
</pre>
</div>
<li \>The ORDER BY clause can be used for sorting the results
<div class='sql'>
<pre>
SELECT u.* FROM User u ORDER BY u.name
</pre>
</div>
<li \>The LIMIT and OFFSET clauses can be used for efficiently limiting the number of records to a given <i>row_count</i>