mysql commands_Mysql常用指令

去重指令

作用:去除select 查询出来的结果中重复的数据,重复数据只展示一列.

关键字:DISTINCT

用法:select DISTINCT source from student_table

source:去重的字段条件

student_table: 表名

查询版本号

select version() --查询系统版本(函数)

用来计算(表达式)

select 100*33 as 计算结果 --用来计算(表达式)

查询自增长步长(变量)

select @@auto_increment_increment --查询自增的步长(变量)

模糊查询

select * from student_table where name like '%刘%' --表示名字中带有刘字的条件;

select * from student_table where name like '刘%' --表示名字以刘字开头的条件;

select * from student_table where name like '刘_' --表示以刘后面只有一个子的条件;

select * from student_table where name like '刘__' --表示以刘后面只有两个字的条件.

is not null 不为空 is null 为空

select * from student_table where birthdate is not null; 查询出生日期不为空的学生信息.

select * from student_table where birthdate is null; 查询出生日期为空的学生信息.

join 联表查询

图示:

76118384bcec0f10fa6cd446a3f78b65.png

结论:inner join 是两边条件都符合的才能执行,null的不算

left join tableone left join tabletwo ,以左边边为准,左边的null能被输出;

文章来源: segmentfault.com,作者:Jame,版权归原作者所有,如需转载,请联系作者。

原文链接:segmentfault.com/a/1190000039028012

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值