条件过滤
select * from 表名;
例如 :select * from zero;
select * fom 表名 where 字段=value;
例如 :select * from zero where id=3;
select * from zero where id between 1 and 3;
select * from zero where id in(1,2,3);
&满足条件一和满足条件二都为true时显示出来
select * from 表名 where 条件一 and 条件二;
|满足条件一和满足条件二都为true时显示出来
select * from 表名 where 条件一 or 条件二;
null值查询
null值无法通过等值查询
select * from 表名 where 字段 is null;
模糊查询
_表示一个任意的字符,%表示零个或多个字符
select * from 表名 where 字段 like 条件;
逻辑运算
包含的符号:>,<,>=,<=,!=等
select * from 表名 where 字段 > value;
排序
升序ASC,降序DESC
先降序,后升序
select * from 表名 order by 字段 desc,字段asc;
分页查询
参数1:起始行;参数2:显示行数。
从第0行开始显示两条数据。
select * from 表名 limit 0,2;
单行函数
length计算长度
select length("123");
select length(字段) from 表;
upper/lower 大,小写转换
select upper("a"),lower("A");
select upper(字段),
select concat('product_category','product_name') from products;
concat字符串拼接
selec concat(字段1,字段2) from 表;