Skip to main content
You can use the query builder to create complex SELECT queries; including joins, subqueries and CTEs. First create a query builder instance:
Then continue building your query:

where

Adds a WHERE condition. Multiple calls to this method result in the conditions AND-ed together.

subquery

innerJoin

INNER JOINs a table. Does not select columns from the joined table. Supports joining by relation, condition or sql.

innerJoinAndSelect

INNER JOINs a table. Selects columns from the joined table. Supports joining by relation, condition or sql.

innerJoinAndMap

INNER JOINs a table. Selects and maps columns from the joined table into entity result. Supports joining by relation, condition or sql.

with

Adds a CTE which you can reference later in your query. First argument is CTE name, second is CTE query.

orderBy

Adds ORDER BY clause. Default is ASC.

getEntities

Returns result parsed into .

getRaw

Returns result as plain objects. Field names are column name as from the SQL query. Return type is automatically generated.