温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

查询mysql数据库表单和使用函数介绍

发布时间:2020-05-13 17:27:21 来源:亿速云 阅读:273 作者:三月 栏目:数据库

下文主要给大家带来查询mysql数据库表单和使用函数,希望这些内容能够带给大家实际用处,这也是我编辑查询mysql数据库表单和使用函数这篇文章的主要目的。好了,废话不多说,大家直接看下文吧。

单表查询

准备一张雇员表company.employee

雇员编号 emp_id   int

雇员姓名 emp_name  varchar(30)

雇员性别 sex  enum

雇用日期 hire_date  date

职位  post  varchar(50)

职位描述 job_description  varchar(50)

薪水 salary double(15,2)

办公室office int

部门编号 dep_id int

 查询mysql数据库表单和使用函数介绍

一、表的简单查询

Select * from employee;  //查看全部

Select 字段1,字段2,...字段n from 表名

避免重复关键字distinct

Select distinct post from employee

关系运算符:+ - * %

Select emp_name salary*12 from employee;

As别名

Select emp_name as姓名 salary*12 as 薪水 from employee;

定义显示格式 concat()函数用于连接字符串

Select concat (emp_name,annual salary ,salary*12) as 员工年薪

 From employee; 

二、通过条件查询

条件查询条件表达式

比较运算符:> <= != >= <=

逻辑运算符and 或者&&  or或者||  xor  not或者!

语法:select 字段1,字段2,字段N from 表名  where condition(条件表达式)

单条件查询

Select emp_name from employee where post =hr

多条件查询

Select emp_name from employee where post=hr and salayr>100000;

关键字查询between and     

Select emp_name from employee

Where salary between 5000 and 15000;  //工资在500015000之间

Select emp_name from employee

Where salary  not  between 5000 and 15000; //  工资不在500015000之间的人

关键字查询is  null

Select emp_name,job_description from employee

Where job_description is  null; // 查看职位描述是空的员工

Select emp_name,job_description from employee

Where job_description is not null; //查看职位描述非空的员工

 对于以上关于查询mysql数据库表单和使用函数,大家是不是觉得非常有帮助。如果需要了解更多内容,请继续关注我们的行业资讯,相信你会喜欢上这些内容的。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI