• 一 基础查询进阶

什么是函数:MySQL服务内置的命令

函数的格式  函数名()

通常使用的方法      函数名(表头名)

也可以单独使用      函数名()

或者 函数里嵌套函数 函数(函数() )

在select 命令里使用函数做查询的格式

第一种格式

SELECT  函数(表头名)  FROM  库名.表名;

第二种格式

SELECT  函数(函数())  ;

第三种格式:单独把函数的执行结果输出

SELECT  函数() ;

常用函数的使用:

1.1  字符函数的使用 

作用:处理字符或字符类型的字段

LENGTH(str)       返字符串长度,以字节为单位

CHAR_LENGTH(str) 返回字符串长度,以字符为单位

UPPER(str)和UCASE(str)  将字符串中的字母全部转换成大写

LOWER(str)和LCASE(str) 将str中的字母全部转换成小写

SUBSTR(s, start,end)  从s的start位置开始取出到end长度的子串

INSTR(str,str1) 返回str1参数,在str参数内的位置

TRIM(s) 返回字符串s删除了两边空格之后的字符串

例子:
mysql> select   name  from  tarena.user where name="root";
+------+
| name |
+------+
| root |
+------+
1 row in set (0.00 sec)mysql> select  char_length(name)  from  tarena.user where name="root";
+-------------------+
| char_length(name) |
+-------------------+
|                 4 |
+-------------------+
1 row in set (0.00 sec)mysql> 

1.2  数学函数的使用  具体函数的使用见案例

作用:处理数据或数值类型的字段

ABS(x) 返回x的绝对值

PI() 返回圆周率π,默认显示6位小数

MOD(x,y) 返回x被y除后的余数

CEIL(x)、CEILING(x) 返回不小于x的最小整数 (x 是小数)

FLOOR(x) 返回不大于x的最大整数 (x 是小数)

ROUND(x) 返回最接近于x的整数,即对x进行四舍五入 (x 是小数)

ROUND(x,y)  返回最接近x的数,其值保留到小数点后面y位,若y为负 值,则将保留到x到小数点左边y位 (x 是小数)

例子:
mysql> select mod(10,3);
+-----------+
| mod(10,3) |
+-----------+
|         1 |
+-----------+
1 row in set (0.01 sec)mysql> select mod(10,3) as 余数;
+--------+
| 余数   |
+--------+
|      1 |
+--------+
1 row in set (0.00 sec)mysql>
mysql> select id , name    from tarena.user where  mod(id,2) = 0 ;
+----+-----------------+
| id | name            |
+----+-----------------+
|  2 | bin             |
|  4 | adm             |
|  6 | sync            |
|  8 | halt            |
| 10 | operator        |
| 12 | ftp             |
| 14 | systemd-network |
| 16 | polkitd         |
| 18 | postfix         |
| 20 | rpc             |
| 22 | nfsnobody       |
| 24 | plj             |
| 26 | mysql           |
| 30 | plj             |
| 32 | halt            |
| 34 | AAA             |
| 36 | bcb             |
+----+-----------------+
17 rows in set (0.00 sec)mysql>  

1.3  聚集函数的使用  sum()  avg()  min()  max()  count()

作用:数据统计命令 ,输出的值只有1个

avg(字段名) //计算平均值

sum(字段名)  //求和

min(字段名)  //获取最小值

max(字段名)  //获取最大值

count(字段名)  //统计字段值个数

例子:
mysql> select min(uid) from  tarena.user;
+----------+
| min(uid)   |
+----------+
|        0       |
+----------+
1 row in set (0.00 sec)
mysql> select min(uid) from  tarena.user where  shell = "/sbin/nologin";
+----------+
| min(uid) |
+----------+
|        1 |
+----------+
1 row in set (0.00 sec)mysql> mysql> select min(uid),max(uid) from  tarena.user;
+----------+----------+
| min(uid) | max(uid) |
+----------+----------+
|        0       |    65534 |
+----------+----------+
1 row in set (0.00 sec)mysql>
mysql> select  name, sum(uid+gid) from tarena.user where name="ftp";
+------+--------------+
| name | sum(uid+gid) |
+------+--------------+
| ftp      |           64 |
+------+--------------+
1 row in set (0.00 sec)mysql> 

1.3日期时间函数的使用  :
使用mysql服务自带的命令 获取系统日期和时间

mysql> system date
2021年 10月 12日 星期二 09:26:20 CST
mysql>
mysql> select now();
+---------------------+
| now()               |
+---------------------+
| 2021-10-12 09:27:39 |
+---------------------+
1 row in set (0.00 sec)mysql> select curdate() ;
+------------+
| curdate()  |
+------------+
| 2021-10-12 |
+------------+
1 row in set (0.00 sec)mysql> select curtime() ;
+-----------+
| curtime() |
+-----------+
| 09:28:55  |
+-----------+
1 row in set (0.00 sec)mysql> select year(20191224);
+----------------+
| year(20191224) |
+----------------+
|           2019 |
+----------------+
1 row in set (0.00 sec)mysql> select year(now());
+-------------+
| year(now()) |
+-------------+
|        2021 |
+-------------+
1 row in set (0.00 sec)
mysql> desc employees;
mysql> select  hire_date from  employees where  employee_id=10;mysql> select  year(hire_date) from  employees where  employee_id=10;mysql> select  month(hire_date) from  employees where  employee_id=12;mysql> select  day(hire_date) from  employees where  employee_id=12;mysql> select  year(now());mysql> select  year(20191224);  #从自定义的日期时间中获取对应的值

1.5  数学计算的使用  +   -     *   /     %  
       符号两边的 字段的是数值类型的

把前5行 用户的uid号分别加1
#先把前5行用户的uid号查出来
mysql> select  id , name , uid  from   tarena.user where  id <= 5;
+----+--------+------+
| id | name   | uid  |
+----+--------+------+
|  1 | root   |    0 |
|  2 | bin    |    1 |
|  3 | daemon |    2 |
|  4 | adm    |    3 |
|  5 | lp     |    4 |
+----+--------+------+
5 rows in set (0.00 sec)#修改
mysql> update  tarena.user set uid=uid+1 where  id <= 5;     修改后查看
mysql>  select  id , name , uid  from   tarena.user where  id <= 5;
+----+--------+------+
| id | name   | uid  |
+----+--------+------+
|  1 | root   |    1 |
|  2 | bin    |    2 |
|  3 | daemon |    3 |
|  4 | adm    |    4 |
|  5 | lp     |    5 |
+----+--------+------+
5 rows in set (0.00 sec)mysql> 再前5行用户的UID还改回去
mysql> update  tarena.user set uid=uid-1 where  id <= 5;
Query OK, 5 rows affected (0.07 sec)
Rows matched: 5  Changed: 5  Warnings: 0mysql>  select  id , name , uid  from   tarena.user where  id <= 5;
+----+--------+------+
| id | name   | uid  |
+----+--------+------+
|  1 | root   |    0 |
|  2 | bin    |    1 |
|  3 | daemon |    2 |
|  4 | adm    |    3 |
|  5 | lp     |    4 |
+----+--------+------+
5 rows in set (0.00 sec)mysql> #显示uid号是偶数的用户名和对应的UIDmysql> select name ,uid from  tarena.user where  uid % 2 =  0;mysql> select name ,uid from  tarena.user where  uid % 2  !=  0;  奇数#显示uid 和 gid  的平均值
mysql> select  name , uid , gid , (uid + gid) / 2  as 平均值  from
tarena.user where name="ftp";
+------+------+------+-----------+
| name | uid  | gid  | 平均值    |
+------+------+------+-----------+
| ftp  |   14 |   50 |   32.0000 |
+------+------+------+-----------+
1 row in set (0.00 sec)mysql> 查询每位员工的年龄
mysql> select  2021 - year(birth_date) as age , name , employee_id from employees;仅查询员工编号是8的员工的年龄
mysql> select  2021 - year(birth_date) as age , name , employee_id
from employees  where employee_id=8 ;把编号8的员工 2020年12 月的奖金减去500#先把复合条件的工资查出来select employee_id , bonus  from  tarena.salary where employee_id =8 and year(date)=2020 and month(date)=12;#修改
mysql> update  tarena.salary set  bonus=bonus-500
where employee_id =8 and year(date)=2020 and month(date)=12;

1.6  流程控制函数 : 查询表记录事可以加判断语句
 if语句 语法格式
 语法:

if(条件,v1,v2) 如果条件是TRUE则返回v1,否则返回v2
ifnull(v1,v2)  如果v1不为NULL,则返回v1,否则返回v2  
演示if() 语句的执行过程

mysql> select  if(1 = 2 , "a","b");
+---------------------+
| if(1 = 2 , "a","b") |
+---------------------+
| b                   |
+---------------------+
1 row in set (0.00 sec)mysql> select  if(1 = 1 , "a","b");
+---------------------+
| if(1 = 1 , "a","b") |
+---------------------+
| a                   |
+---------------------+
1 row in set (0.00 sec)mysql> 演示ifnull() 语句的执行过程mysql> select  ifnull("abc","xxx");
+---------------------+
| ifnull("abc","xxx") |
+---------------------+
| abc                 |
+---------------------+
1 row in set (0.00 sec)mysql> select  ifnull(null,"xxx");
+--------------------+
| ifnull(null,"xxx") |
+--------------------+
| xxx                |
+--------------------+
1 row in set (0.00 sec)mysql> 查询例子
mysql> select name , uid  , if(uid < 1000 , "系统用户","创建用户") as 用户类型 from tarena.user;
mysql> select name , shell  , if(shell = "/bin/bash" , "交互用户","非交户用户") from tarena.user;
插入家目录是空的用户
mysql> insert   into   tarena.user (name, homedir) values ("jerrya",null);查看没有家目录的用户
mysql> select name , homedir  from  tarena.user where homedir is null ;
mysql>查看的时候加判断
mysql> select name  姓名, ifnull(homedir,"NO  home") from  tarena.user;  mysql> select name  姓名, ifnull(homedir,"NO  home")as 家目录  from  tarena.user;
+-----------------+--------------------+
| 姓名            | 家目录             |
+-----------------+--------------------+
| root            | /root              |
| bin             | /bin               |
| daemon          | /sbin              |
| adm             | /var/adm           |
| lp              | /var/spool/lpd     |
| sync            | /sbin              |
| shutdown        | /sbin              |
| halt            | /sbin              |
| mail            | /var/spool/mail    |
| operator        | /root              |
| games           | /usr/games         |
| ftp             | /var/ftp           |
| nobody          | /                  |
| systemd-network | /                  |
| dbus            | /                  |
| polkitd         | /                  |
| sshd            | /var/empty/sshd    |
| postfix         | /var/spool/postfix |
| chrony          | /var/lib/chrony    |
| rpc             | /var/lib/rpcbind   |
| rpcuser         | /var/lib/nfs       |
| nfsnobody       | /var/lib/nfs       |
| haproxy         | /var/lib/haproxy   |
| NULL            | NO home            |
| NULL            | NO home            |
|                 | NO home            |
| null            | NO home            |
| NULL            | NO home            |
| NULL            | NO home            |
| yaya9           | NO home            |
| 6yaya           | NO home            |
| ya7ya           | NO home            |
| yay8a           | NO home            |
| jerrya          | NO home            |
+-----------------+--------------------+
34 rows in set (0.00 sec)

case语句 语法格式  (可以有多个判断添加)

如果字段名等于某个值,则返回对应位置then后面的结果,
如果与所有值都不相等,则返回else后面的结果

语法格式1
CASE 字段名
WHEN 值1 THEN 结果
WHEN 值2 THEN 结果
WHEN 值3 THEN 结果
ELSE 结果
END 语法格式2
CASE
WHEN  判断条件 THEN 结果
WHEN  判断条件  THEN 结果
WHEN  判断条件 THEN 结果
ELSE 结果
END
例子
select dept_id, dept_name,
case dept_name
when '运维部' then '技术部门'
when '开发部' then '技术部门'
when '测试部' then '技术部门'
when null then '未设置'
else '非技术部门'
end as  部门类型   from  tarena.departments;或
select dept_id, dept_name,
case
when  dept_name='运维部'  then  "技术部"
when  dept_name='开发部'  then  "技术部"
when  dept_name='测试部' then   "技术部"
when dept_name is null   then "未设置"
else "非技术部"
end as 部门类型
from departments;

三 查询结果处理

查询结果处理: 对用select 命令查找到的数据再做处理, 

类似于系统命令管道  |       

例如  ps  aux  |   grep  httpd 

语法格式1

select    字段名列表  from   库.表    分组|排序|过滤|分页 ;

语法格式2

select    字段名列表  from   库.表   where  筛选条件    分组|排序|过滤|分页 ;

3.1 分组 :  对查找到数据做分组处理(表头值相同为一组,只显示一次) 。   

命令    group by   字段名

例子
#查看shell的种类
mysql> select shell  from  tarena.user group by shell;统计使用每种shell的用户个数
mysql> select count(name), shell  from  tarena.user group by  shell;#查看每个部门的人数
mysql>select dept_id, count(name)  from tarena.employees group by  dept_id;3.2 排序  把查找到的数据排队 ,用来排队的字段数据类型应该是 数值类型命令
order by   字段名   [asc];     从小到大排序(升序)默认的排序方式
order by   字段名   desc;   从大到小排序(降序)例子
查看满足条件记录的name和uid 字段的值
mysql> select name , uid from  user where uid is not null;  #按照uid升序排序
mysql> select name , uid  from  user where uid is not null  order by   uid ; #按照uid降序排序
mysql> select name , uid from  user where uid is not null  order by   uid   desc;把2018 年每个员工的总收入由高到底排序 #查看每个员工的总收入
select employee_id, sum(basic+bonus) as total from tarena.salary
where year(date)=2018 group by employee_id ;#按总收入降序排队
select employee_id, sum(basic+bonus) as total from tarena.salary
where year(date)=2018 group by employee_id order by total desc;运算符 和 统计函数的区别
运算符 横着计算
统计函数 竖着计算
sum(basic+bonus) 的解释mysql> select id ,uid+gid from user where id <= 3;
+----+---------+
| id | uid+gid |
+----+---------+
|  1 |       0 |
|  2 |       2 |
|  3 |       4 |
+----+---------+
3 rows in set (0.00 sec)mysql> select uid+gid from user where id <= 3;
+---------+
| uid+gid |
+---------+
|       0 |
|       2 |
|       4 |
+---------+
3 rows in set (0.00 sec)mysql> select sum(uid+gid) from user where id <= 3;
+--------------+
| sum(uid+gid) |
+--------------+
|            6 |
+--------------+
1 row in set (0.00 sec)mysql>
总结 :  不加sum  横着加   加了sum  竖着加查询每个部门的人数
select    dept_id , name   from   tarena.employees ;
select    dept_id , count(name)   from   tarena.employees  group by dept_id;查询每个部门中年龄最大的员工
select   dept_id,birth_date  from  tarena.employees;select   dept_id, min(birth_date)  from  tarena.employees group by  dept_id;查询每个部门入职最晚员工的入职时间
mysql> select dept_id, max(hire_date) from employees group by dept_id;统计各部门使用tedu.cn邮箱的员工人数
select  dept_id ,name from  tarena.employees  where   email like "%tedu.cn" ;select  dept_id ,count(name) from   tarena.employees
where   email like "%tedu.cn"  group by  dept_id;查询2015年1月10号员工工资情况,以基本工资进行降序排列;如果基本工资相同,再以奖金升序排列
select date, employee_id, basic, bonus from tarena.salary
where date='20150110' order by basic desc , bonus  asc;查询2015年1月10号员工工资情况,以工资总额升序排序
select employee_id , basic , bonus , basic+bonus as total
from tarena.salary   where  date='20150110';select employee_id , basic , bonus , basic+bonus as total
from tarena.salary   where  date='20150110'    order by total ; 

3  过滤数据 having 

作用对select 查询到的数据 再次做筛选 使用的命令是having  

格式1
select  字段名列表  from   库.表     having   筛选条件;格式2
select  字段名列表  from   库.表  where   条件     having   筛选条件;

查询部门人数少于5人

select  dept_id ,  name    from   tarena.employees;select  dept_id ,  count(name)   from   tarena.employees  group  by  dept_id ;mysql> select  dept_id ,  count(name)   from   tarena.employees  group  by  dept_id  having count(name)<5;

4  分页 limit 

作用:限制查询结果显示行数(默认显示全部的查询结果)

使用SELECT查询时,如果结果集数据量很大,比如1万行数据,放在一个页面显示的话数据量太大,不如分页显示,比如每次只显示100行  100次显示完

命令格式1  (只显示查询结果的头几行)

select  字段名列表  from   库.表  limit 数字;

select  字段名列表  from   库.表  where   条件  limit 数字;

例如
limit   1  ;  只显示查询结果的第1行
limit   3  ;  显示查询结果的前3行
limit   10  ;  显示查询结果的前10行

命令格式2 (显示查询结果指定范围内的行)

select  字段名列表  from   库.表  limit 数字1,数字2;

select  字段名列表  from   库.表  where   条件  数字1,数字2;

数字1   表示起始行   第1行用数字0表示   第2行用数字1表示   第3行用数字2表示

数字2  表示显示的总行数

例如

limit   0 , 1 ; 从查询结果的第1行开始显示,共显示1行limit   3, 5;      从查询结果的第4行开始显示,共显示5行limit   10,10       从查询结果的第11行开始显示,共显示10行

只显示查询结果的第1行

mysql> select name,uid , gid  , shell  from tarena.user where shell is not null ;mysql> select name,uid , gid  , shell  from tarena.user where shell is not null  limit 1;

只显示查询结果的前3行

mysql> select name,uid , gid  , shell  from tarena.user  where shell is not null ;mysql> select name,uid , gid  , shell  from tarena.user  where shell is not null  limit  3;

只显示查询结果的第1行 到 第3

mysql> select name,uid , gid  , shell  from user   where shell is not null;
mysql> select name,uid , gid  , shell  from user   where shell is not null  limit 0,3;

从查询结果的第4行开始显示共显示3行 (0 表示查询结果的第1行)

mysql> select name,uid , gid  , shell  from user  where shell is not null  limit 3,3;

其他例子

select   name , uid , shell   from   user where  uid  between 10 and  100
order  by   uid  desc  limit    1  ;select   name , uid , shell   from   user where  uid  between 10 and  100  order  by   uid  desc  limit    3  ;mysql> select  * from  tarena.user where id <= 10;
mysql> select  * from  tarena.user where id <= 10    limit    1;mysql> select  * from  tarena.user where id <= 10  limit   2 , 3; 

比如从表里查询 100条记录  想分5页显示   100/5 = 20   每页显示20条记录

程序员在脚本里写查询命令

select   * from  tarena.user  limit   0, 20; 显示第一页的查询命令
select   * from  tarena.user  limit  20,20; 显示第二页的查询命令
select   * from  tarena.user  limit  40,20;显示第三页的查询命令
select   * from  tarena.user  limit  60,20;显示第四页的查询命令
select   * from  tarena.user  limit  80,20;显示第五页的查询命令

看到一个对表数据做处理的要求时,分析出sql语句怎么写的思路

第1步: 确定使用的命令

(对数据做处理使用那个命令  select   update   insert  delete )

第2步: 确定数据在那个表里

(可以确定  from  后的 表名)

第3步: 确定处理的是什么数据

(就知道了 表头名  了)

第4步: 确定处理条件

(就知道 where 后边该怎么写了 )

二、连接查询

连接查询:把多张表 通过连接条件 组成1张新表  ,然后在组成的新表里查找数据

在工作中 ,不是把所有数据都放在一张表里存储,把数据找全就得从多张表里一起找。

总结:

连接查询也叫多表查询 常用于查询字段来自于多张表

通过不同连接方式把多张表重新组成一张新表对数据做处理

如果直接查询两张表,将会得到笛卡尔积 (2张表里行数相乘的积)

通过添加有效的条件可以进行查询结果的限定

例子:

mysql> create table tarena.t1 select name,homedir from tarena.user limit 2;
mysql> create table tarena.t2 select name ,uid ,shell from tarena.user limit 4 ;use tarena;
mysql> select  *  from  t1,t2;
+------+---------+--------+------+---------------+
| name | homedir | name   | uid  | shell         |
+------+---------+--------+------+---------------+
| root | /root   | root   |    0 | /bin/bash     |
| bin  | /bin    | root   |    0 | /bin/bash     |
| root | /root   | bin    |    1 | /sbin/nologin |
| bin  | /bin    | bin    |    1 | /sbin/nologin |
| root | /root   | daemon |    2 | /sbin/nologin |
| bin  | /bin    | daemon |    2 | /sbin/nologin |
| root | /root   | adm    |    3 | /sbin/nologin |
| bin  | /bin    | adm    |    3 | /sbin/nologin |
+------+---------+--------+------+---------------+
8 rows in set (0.00 sec)mysql>
mysql> select  *  from  t1,t2 where t1.name = t2.name ;
+------+---------+------+------+---------------+
| name | homedir | name | uid  | shell         |
+------+---------+------+------+---------------+
| root | /root   | root |    0 | /bin/bash     |
| bin  | /bin    | bin  |    1 | /sbin/nologin |
+------+---------+------+------+---------------+
2 rows in set (0.00 sec)

连接查询分类

按功能分类

内连接

外连接

交叉连接

按年代分类

SQL92标准:仅支持内连接

SQL99标准:支持所功能的连接

SQL99标准多表查询 的语法

格式:

SELECT 字段列表  FROM 表1 [AS] 别名  [连接类型]   JOIN   表2 [AS] 别名
ON 连接条件   WHERE 筛选条件 ;或
SELECT 字段列表  FROM 表1 [AS] 别名  [连接类型]   JOIN   表2 [AS] 别名
ON 连接条件
WHERE 筛选条件
GROUP BY 分组  |  HAVING 分组后筛选条件 |  ORDER BY 排序字段  

连接查询 之 内连接  

语法格式

SELECT  字段列表
FROM  表1  别名
INNER JOIN  表2  别名  ON 连接条件  INNER JOIN  表3  别名  ON 连接条件
[WHERE 筛选条件]
[GROUP BY 分组]
[HAVING 分组后筛选]
[ORDER BY 排序列表]

连接查询 之 内连接  根据连接条件的不同又分为:

等值连接:使用相等判断做连接条件

非等值连接:连接条件不是相等判断

自连接:  自己连接自己,把1张表当做2张表(需要给表定义别名)

通过例子了解连接方式的使用

1) 查询每个员工所在的部门名

select name, dept_name
from employees inner join departments  on employees.dept_id=departments.dept_id;

显示员工编号8 的 员工所在部门的部门名称;

mysql> select employee_id , name , dept_name from employees , departments
where employees.dept_id = departments.dept_id and employees.employee_id=8;
+-------------+--------+-----------+
| employee_id | name   | dept_name |
+-------------+--------+-----------+
|           8 | 汪云   | 人事部    |
+-------------+--------+-----------+
1 row in set (0.00 sec)

内连接的等值连接例子

select  name, dept_name  from employees  inner join departments
on employees.dept_id=departments.dept_id;

查询每个员工所在的部门名,使用别名(给表定义别名)

select d.dept_name , e.*
from employees as e inner join departments as d on e.dept_id=d.dept_id;

把表连接后,加条件 查找符合条件的数据

select d.dept_name , e.*
from employees as e inner join departments as d on e.dept_id=d.dept_id
where  d.dept_id=3;

查询每个员工所在的部门名,使用别名。两个表中的同名字段,必须指定表名

select  dept_id  from   employees  inner join departments  on
employees.dept_id=departments.dept_id;
ERROR 1052 (23000): Column 'dept_id' in field list is ambiguousselect  employees.dept_id  from   employees  inner join departments  on  employees.dept_id=departments.dept_id;select  e.dept_id ,d.dept_id ,e.name from   employees as e  inner join departments as d on  e.dept_id=d.dept_id;

查询11号员工的名字及2018年每个月工资

select   e.employee_id,  name, date, basic+bonus as total
from employees as e   inner join salary as s
on e.employee_id=s.employee_id
where year(s.date)=2018 and e.employee_id=11;

查询2018年每个员工的总工资

  #没分组前
select name,date,basic,bonus  from employees inner join salary
on employees.employee_id=salary.employee_id  where  year(date)=2018;  # 分组后
select name, sum(basic+bonus) from employees inner join salary
on employees.employee_id=salary.employee_id
where year(date)=2018    group by name;

查询2018年每个员工的总工资,按工资升序排列

 mysql> select name, sum(basic+bonus) as total  from employees inner join salary on employees.employee_id=salary.employee_id where year(salary.date)=2018 group by name order by total asc;

departments 部门表
mysql> desc tarena.departments;
dept_id 部门编号
dept_name 部门名称

employees 员工表
mysql> desc tarena.employees;
employee_id 员工编号
name 员工姓名
hire_date 入职日期
birth_date 生日
email 邮箱
phone_number 电话号码
dept_id 部门编号 (外键 参考departments表里 dept_id表头)

salary 工资
id 行号
date 发工资的日期
employee_id 员工编号 (外键 参考employees表的 employee_id 表头)
basic 基本工资
bonus 奖金

Mysql---基础查询进阶、流程控制语句相关推荐

  1. T-SQL查询进阶--流程控制语句

    和其他高级语言一样,T-SQL中也有用于控制流程的语句.T-SQL中的流程控制语句进一步扩展了T-SQL的力量--使得大部分业务逻辑可以在数据库层面进行.但很多人对T-SQL中的流程控制语句并没有系统 ...

  2. 1204、基础查询进阶、连接查询

    文章目录 一.基础查询进阶 1.常用函数 1.1 字符函数 1.2 数学函数 1.3 聚集函数 1.4 日期函数 1.5 数学计算的使用 + - \* / % **2.流程控制函数:查询表记录事可以加 ...

  3. java跳转控制语句有哪些_Java语言基础学习之流程控制语句和跳转控制语句实例分析...

    本文主要向大家介绍了Java语言基础学习之流程控制语句和跳转控制语句实例分析,通过具体的内容向大家展示,希望对大家学习JAVA语言有所帮助. 一.流程控制语句 在一个程序执行的过程中,各条语句的执行顺 ...

  4. MySQL连接查询——MySQL 基础查询你会了吗?

    前言: 由于大一学习数据库不扎实,学到后面有点吃力,所以回过头来认真学习一边,写一些学习总结,提醒自己.也要告诫读者,把基础打扎实.读者觉得有用的话可以收藏点赞哦! 上一篇:MySQL函数查询--My ...

  5. java基础起步三-流程控制语句中的条件语句

    文章目录 流程控制语句结构: 1. 顺序结构 2. 分支结构 3. 循环结构 分支结构语法: 1. 单分支结构; 2. 双分支结构 3. 多分支条件语句: 选择结构 语法: 注意: 输入输出案例 练习 ...

  6. Mysql基础到进阶精品视频教程附讲义文档 91课

    课程介绍 Mysql基础 本章主要是php开发中Mysql基础知识的学习,包括MySQL的简单介绍和安装.MySQL管理工具的使用.表的建立.数据的查询.数据的修改和数据的增加等等,全面掌握php网站 ...

  7. mysql 基础命令进阶

    文章目录 基础命令回顾 数据类型 常用SELECT命令 导入数据库 导出数据库 扩展知识 SQL查询语句进阶 连接查询: 破解mysql数据库密码 基础命令回顾 添加字段: alter table 表 ...

  8. mysql 113_MySQL教程113-MySQL流程控制语句

    在存储过程和自定义函数中可以使用流程控制语句来控制程序的流程.MySQL 中流程控制语句有:IF 语句.CASE 语句.LOOP 语句.LEAVE 语句.ITERATE 语句.REPEAT 语句和 W ...

  9. python语言流程控制语句的格式_慢步学python,编程基础知识,流程控制语句if

    慢步业余学python编程,今天休息继续分享python编程知识. 面向过程编程,重要的是程序的流程,今天说说流程控制语句if. 在我们高中数学中就有流程图的学习,只是没有真正应用起来而已,办公软件也 ...

  10. JS基础02之流程控制语句

    if-else-if多分支语句 练习案例1 说明:输入学生的成绩并根据成绩给出相应的等级, 等级评定标准: 成绩在90–100(包含)之间,显示 A,成绩在80–90(包含)之间, 显示 B,成绩在7 ...

最新文章

  1. 千里之行,始于OKR——轻雀协作团队管理分享
  2. SAP中的BOPF(Business Object Processing Framework)
  3. 十分钟了解分布式计算:GraphLab
  4. erp系统方案书_解决方案 |快普M8为系统集成企业定制的ERP系统
  5. java 去掉 t_关于Java:在LocalDateTime中不能删除“ T”
  6. 代码校验工具 SublimeLinter 的安装与使用
  7. css媒体查询和居中
  8. RGBA 图片格式转换 RGB 无损
  9. 微软推出 Go 语言免费中文教程,真香!
  10. 8个免费图片素材网,赶紧收藏起来
  11. 5次Shift破解Win7登录密码
  12. 作网站需要服务器吗,如何制作网站服务器
  13. 6个自学python必看网站
  14. 华为交换机RRPP环协议
  15. 微信小程序周报(第十二期)-极乐小程序商店出品
  16. ZYNQ之AXI简介
  17. android kotlin 上传文件 上传图片
  18. 人生最不该挥霍的3样东西
  19. 你经历过绝望吗?两次!
  20. 【陈工笔记】# Latex中,bib格式转换为bbl格式文件 #

热门文章

  1. Python_Flask
  2. 澳洲八大的IB(International Baccalaureate)成绩录取要求
  3. 简述计算机用二进制的原因,简述计算机采用二进制的原因
  4. (17)雅思屠鸭第十七天:小作文完整攻略
  5. 【计算机网络】 如何看懂路由表
  6. 根据微信返回的头像url选择所需尺寸图片
  7. CreateCompatibleDC 和 CreateCompatibleBitmap
  8. 最新ncRNA数据库大全(含TCGA、ceRNA、exosome等)
  9. excel文件下载下来损坏 js_使用Java / javascript和apache POI导出.xls文件时获取损坏的文件...
  10. 关于4次挥手时等待2MSL的问题