提前
我喜欢用小写,并没有具体分类,浅看就好
命名
col
代表列名
col_name1 | col_name2 |
---|---|
我是数据 | 我也是数据 |
data
代表数据,具体是啥数据并不重要
select
where
没错,是条件,不多bb废话
and
和or
用于连接条件
条件
关键字 | 意思 | 例子 |
---|---|---|
= , != , < ,<= , > , >= | 额…没啥好说的 | col_name = data |
between data1 and data2 | 在data1 和data2 之间,区间是[data1,data2] | col_name between data1 and data2 |
not between data1 and data2 | 不在data1 和data2 之间,区间同上取反 | col_name not between data1 and data2 |
in (data...) | (data...) 中存在 | col_name in (data1 , data2 ) |
not in (data...) | (data...) 中不存在 | col_name not in (data1 , data2 ) |
like | 模糊查询,需要通配符,没有用通配符等价于 = | col_name like data可使用通配符 |
not like | 模糊查询取反 | col_name not like data可使用通配符 |
regexp | 正则表达式 | col_name regexp data可使用正则表达式 |
not regexp | 正则表达式取反 | col_name not regexp data可使用正则表达式 |
通配符%
表示0个或多个字符
通配符_
表示一个字符
在我目前看来 not
就是取反
参考
自学SQL网 (推荐,蛮不错的)