@TOCMySQL的一些稍复杂的查询语句
一、普通查询
select 所查询字段名 from 表名 where 条件
select: 代表查询
from: 来自
where: 有什么条件
示例: select * from work *代表所有字段
二、查询去重
select distinct 字段名 from work;
distinct:代表去重
示例:select distinct estimate from work;
对比:select estimate from work;
三、查询某字段的值区间
select * from 表名 where 字段名 between 开始数值 and 结束数值;
between:代表那个区间(包括起始终点)
and:与
示例:select * from work where salary between 3000 and 8000;
第二种方式:select * from 表名 where 字段名 >字段代表数值 and 字段名 <字段代表数值;
直接用< ,>进行限制,中间用an连接
示例:select * from work where salary > 3000 and salary <8000;
四、查询某字段的特定值
select * from 表名 where 字段名 in (数值1,数值2,数值3,…);
in(…):代表包括的数值,数值中间用" , "隔开.
示例:select * from work where salary in (3000,4500,8000);
五、查询包含特定某几个字段数值的信息(包含任意一个即可)
select * from 表名 where 字段名=‘数值’ or 字段名=‘数值’ ;
or:代表或者
字段名=‘数值’() 记得给数值加 ’ ’
示例:select * from work where salary=‘3000’ or post=‘员工’;
所写所有信息中有不好理解的地方请谅解,未完结,还有下文.