Selects
Specifying A Select Clause
Of course, you may not always want to select all columns from a database table. Using the from
method, you can specify a custom from
clause for the query:
Individual columns can contain fully-qualified names (i.e. "some_table.some_column"), fully-qualified names with table aliases (i.e. "alias.some_column"), and even set column aliases themselves (i.e. "some_column AS c"). Columns can be a single column, a list or columns (comma-separated), or an array of columns.
The distinct
method allows you to force the query to return distinct results:
(Note that distinct
applies to the entire query, not just certain fields.)
If you already have a query builder instance and you wish to add a column to its existing select clause, you may use the addSelect
method:
Last updated