标题:mysql学习第7天查询子句详解where 和group详解

-------------------------------------------------------------------------------------------------------------------------------

时间:2012/4/22 18:03:57

-------------------------------------------------------------------------------------------------------------------------------

内容:

select * from table where


where 后面是表达式
在这以后上表达式是不是诚意

select * from table where 1=1 就全部行
select * from table where id>100

select * from table where id>parentid
where 配合算术表达式
<,>,>=,<=,<>,!=,=,
在值的范围内大于100小于10
between 10 and 100,
具体值举例 值是a,b,c,d都算复合
包含in (a,b,c,d)

也可以用逻辑表达式
大于10小于100
where id<100 and id<10
where id between 10 and 100;

not !
and  &&
or  ||

模糊查询
like
%任意字符
_ 单个字符

比如查ab开头的
ab%
比如查3位字符a开头的
a__


group语法
max min sum count 总行数
avg

max(price)
把列名字当参数看



select * from table where

where 后面是表达式
在这以后上表达式是不是诚意

select * from table where 1=1 就全部行
select * from table where id>100

select * from table where id>parentid
where 配合算术表达式
<,>,>=,<=,<>,!=,=,
在值的范围内大于100小于10
between 10 and 100,
具体值举例 值是a,b,c,d都算复合
包含in (a,b,c,d)

也可以用逻辑表达式
大于10小于100
where id<100 and id<10
where id between 10 and 100;

not !
and  &&
or  ||

模糊查询
like
%任意字符
_ 单个字符

比如查ab开头的
ab%
比如查3位字符a开头的
a__


group语法
max min sum count 总行数
avg

max(price)
把列名字当参数看