登录
首页 >  数据库 >  MySQL

Mysql常用指令

来源:SegmentFault

时间:2023-02-21 18:06:59 501浏览 收藏

大家好,今天本人给大家带来文章《Mysql常用指令》,文中内容主要涉及到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 联表查询

图示:

image.png

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

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
















到这里,我们也就讲完了《Mysql常用指令》的内容了。个人认为,基础知识的学习和巩固,是为了更好的将其运用到项目中,欢迎关注golang学习网公众号,带你了解更多关于mysql的知识点!

声明:本文转载于:SegmentFault 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>
评论列表