Skip to content

WHERE Clause

一句话解释

WHERE clause 筛选行 in 查询 — 仅行 哪里条件是 真是 包含 in result.

用大白话说

WHERE clause is how you filter rows in a SQL query. It takes a condition (an expression that evaluates to true, false, or NULL) and keeps only the rows where the condition is true.

You can combine conditions with AND, OR, and NOT. Common operators include =, !=, <, >, LIKE (pattern matching), IN (membership in a list), BETWEEN (range), and IS NULL (null check).

WHERE is used in SELECT, UPDATE, and DELETE — it determines which rows to read, modify, or remove. It is applied before grouping, so you cannot use aggregate functions in WHERE (use HAVING for that).

示例

sql
-- Find users who are active and over 18
SELECT * FROM users
WHERE active = TRUE AND age > 18;

-- Pattern matching with LIKE
SELECT * FROM users WHERE email LIKE '%@example.com';

首先查询筛选通过 two 条件使用 AND. 其次 uses LIKE for 模式 matching.

相关术语

相关资源

相关课程

解读错误信息

用大白话解释常见错误——什么意思、为什么发生、如何修复。

查看错误

← 返回术语表