WHERE clause
The part of a query that keeps only the rows for which a condition is true.
In more detail
The condition is evaluated once per row; rows where it is false or unknown are dropped. In UPDATE and DELETE it chooses which rows change, so leaving it out changes every row. WHERE runs before grouping, which makes it the place for conditions about individual rows.
Examples
Scoped repositories and row-level security add the tenant WHERE clause automatically.SELECT name, city FROM customers WHERE country = 'NG';Related terms
- SQL — The standard language for defining, querying and changing data in a relational database.
- Where operator — The LINQ operator that keeps only the items for which a predicate returns true.
- IQueryable<T> — The .NET interface for a query that a provider such as EF Core translates and runs elsewhere, typically as SQL in a database.
- predicate — A function or condition that answers true or false about a value, used to filter, search or check data.
- row-level security — A database feature that filters which rows each query may see or change, using policies the database enforces itself.
- logical operator — An operator such as AND, OR or NOT that combines or reverses true-or-false conditions.
- HAVING — The clause that filters groups after aggregates have been calculated, such as keeping customers with at least two orders.
- three-valued logic — SQL's rule that a condition can be true, false or unknown, where unknown comes from comparing with NULL.
Taught in
- Thirty Eight Percent More: Billing Models And Tags — CompTIA Cloud+ (CV0-004) Exam Prep
- Collections, Generics, and LINQ — Modern .NET Core, C# & Enterprise Microservices
- Multi-Tenant Identity: Tenant Isolation & Middleware — Production Full-Stack Engineering
- Filtering With The WHERE Clause — PostgreSQL, Indexing & Relational Data Modeling
- The Difference Between WHERE And HAVING — PostgreSQL, Indexing & Relational Data Modeling
- Updating And Deleting Safely — PostgreSQL, Indexing & Relational Data Modeling