A single column
Select a single column:
Column with a table
Select a single column and specify a table:
Multiple columns
Select multiple columns:
Aliases
You can give an alias for selections and tables by appending as the_alias to the name:
Complex selections
You can select arbitrary expression including subqueries and raw sql snippets.
Not null
Sometimes you can be sure something's not null, but Kysely isn't able to infer
Function calls
This example shows how to create function calls. These examples also work in any
Distinct
The API documentation is packed with examples. The API docs are hosted here,
Distinct on
The API documentation is packed with examples. The API docs are hosted here,
All columns
The selectAll method generates SELECT *:
All columns of a table
Select all columns of a table:
Nested array
While kysely is not an ORM and it doesn't have the concept of relations, we do provide
Nested object
While kysely is not an ORM and it doesn't have the concept of relations, we do provide
Generic find query
A generic type-safe helper function for finding a row by a column value: