这个WHERE
命令过滤结果集以仅包含满足指定条件的记录。
以下 SQL 语句从 "Customers" 表中的 "Mexico" 选择所有客户:
SQL 需要将文本值用单引号括起来(大多数数据库系统也允许双引号)。
但是,数字字段不应括在引号中:
笔记:WHERE子句不仅用在SELECT语句中,它还用在UPDATE、DELETE语句等中!
WHERE 子句中可以使用以下运算符:
Operator | Description |
---|---|
= | Equal |
<> | Not equal. Note: In some versions of SQL this operator may be written as != |
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
BETWEEN | Between a certain range |
LIKE | Search for a pattern |
IN | To specify multiple possible values for a column |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!