Basic Select
Select all columns from a table:Partial Select
Select specific columns from a table:Filtering with Where
Use thewhere() method to filter results:
Ordering Results
UseorderBy() to sort query results:
Limiting and Offsetting
Control the number of results returned:Distinct
Select only distinct values:Group By
Group results by one or more columns:Having Clause
Filter grouped results:Set Operations
Combine multiple select queries:Conditional Where
Build dynamic queries with conditional logic:With Clause (CTE)
Use Common Table Expressions:For Update (PostgreSQL)
Lock rows for update:Conditional Operators Reference
Comparison
eq()- Equal tone()- Not equal togt()- Greater thangte()- Greater than or equallt()- Less thanlte()- Less than or equal
Logical
and()- Combine with ANDor()- Combine with ORnot()- Negate condition
Patterns
like()- Pattern matchingilike()- Case-insensitive patternnotLike()- Not matching patternnotIlike()- Case-insensitive not matching
Ranges & Sets
between()- Between two valuesnotBetween()- Not between valuesinArray()- In array of valuesnotInArray()- Not in array
Null Checks
isNull()- Is NULLisNotNull()- Is NOT NULL
Subqueries
exists()- Subquery has resultsnotExists()- Subquery has no results
Type Safety
Drizzle ensures complete type safety:All query methods are fully typed, providing autocomplete and compile-time type checking.
Next Steps
Joins
Learn about joining tables together
Aggregations
Use aggregate functions like count, sum, avg
Subqueries
Write complex nested queries
Insert
Insert data into tables