MySql查询语句(1)

@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=‘员工’;

在这里插入图片描述
所写所有信息中有不好理解的地方请谅解,未完结,还有下文.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值