【MySQL】复合查询

发布于:2024-08-14 ⋅ 阅读:(74) ⋅ 点赞:(0)

本章节使用到的数据库在最后

基本查询回顾

  1. 查询工资高于500或岗位为MANAGER的雇员,同时还要满足他们的姓名首字母为大写的J
select * from EMP where (sal>500 or job='MANAGER') and ename like 'J%';
  1. 按照部门号升序而雇员的工资降序排序
select * from EMP order by deptno, sal desc;
  1. 使用年薪进行降序排序
select ename, sal*12+ifnull(comm,0) as '年薪' from EMP order by 年薪 desc;
  1. 显示工资最高的员工的名字和工作岗位
select ename, job from EMP where sal = (select max(sal) from EMP);
  1. 显示工资高于平均工资的员工信息
select ename, sal from EMP where sal>(select avg(sal) from EMP);
  1. 显示每个部门的平均工资和最高工资
select deptno, format(avg(sal), 2) , max(sal) from EMP group by deptno;
  1. 显示平均工资低于2000的部门号和它的平均工资
select deptno, avg(sal) as avg_sal from EMP group by deptno having avg_sal<2000;
  1. 显示每种岗位的雇员总数,平均工资
select job,count(*), format(avg(sal),2) from EMP group by job;

多表查询(多表笛卡尔积)

实际开发中往往数据来自不同的表,所以需要多表查询。本节我们用一个简单的公司管理系统,有三张表emp,dept,salgrade来演示如何进行多表查询。

  1. 显示雇员名、雇员工资以及所在部门的名字因为上面的数据来自emp和dept表,因此要联合查询
    在这里插入图片描述
    而上面这种类似于排列组合的样例就叫做笛卡尔积。
    其实我们只要emp表中的deptno = dept表中的deptno字段的记录
select EMP.ename, EMP.sal, DEPT.dname from EMP, DEPT where EMP.deptno = DEPT.deptno;
  1. 显示部门号为10的部门名,员工名和工资
select dname,ename,sal,emp.deptno from emp,dept where emp.deptno=dept.deptno and emp.deptno=10;
  1. 显示各个员工的姓名,工资,及工资级别
select ename,sal,grade from emp,salgrade where sal between salgrade.losal and salgrade.hisal;

自连接

自连接是指在同一张表连接查询,就比如emp这张表,因为这张表中是存放员工的信息的,也就是有员工的上级是谁,当然老板没有上级,但是老板也属于emp表中,本质上也属于员工,所以如果我们要找到一名员工的上级的话就可以使用自连接的方式查询。

显示员工FORD的上级领导的编号和姓名(mgr是员工领导的编号–empno)

  1. 使用子查询
首先我们可以先查到FORD的员工号
mysql> select empno from emp where ename='FORD';
+--------+
| empno  |
+--------+
| 007902 |
+--------+
1 row in set (0.00 sec)

在进行进一步的查询
mysql> select empno,ename from emp where empno=(select empno from emp where ename='FORD');
+--------+-------+
| empno  | ename |
+--------+-------+
| 007902 | FORD  |
+--------+-------+
1 row in set (0.00 sec)
  1. 使用自连接查询
mysql> select e2.empno,e2.ename from emp e1,emp e2 where e2.ename='FORD' and e1.mgr=e2.empno;
+--------+-------+
| empno  | ename |
+--------+-------+
| 007902 | FORD  |
+--------+-------+
1 row in set (0.00 sec)

子查询与where

单行子查询

所谓单行子查询就是查询出来的结果只有一行。

  • 显示SMITH同一部门的员工
---首先查询SMITH的部门,出现的只有一行。

mysql> select deptno from emp where ename='SMITH';
+--------+
| deptno |
+--------+
|     20 |
+--------+
1 row in set (0.00 sec)
---再根据上面查询到的单行数据,进行子查询。

mysql> select * from emp where deptno=(select deptno from emp where ename='SMITH');
+--------+-------+---------+------+---------------------+---------+------+--------+
| empno  | ename | job     | mgr  | hiredate            | sal     | comm | deptno |
+--------+-------+---------+------+---------------------+---------+------+--------+
| 007369 | SMITH | CLERK   | 7902 | 1980-12-17 00:00:00 |  800.00 | NULL |     20 |
| 007566 | JONES | MANAGER | 7839 | 1981-04-02 00:00:00 | 2975.00 | NULL |     20 |
| 007788 | SCOTT | ANALYST | 7566 | 1987-04-19 00:00:00 | 3000.00 | NULL |     20 |
| 007876 | ADAMS | CLERK   | 7788 | 1987-05-23 00:00:00 | 1100.00 | NULL |     20 |
| 007902 | FORD  | ANALYST | 7566 | 1981-12-03 00:00:00 | 3000.00 | NULL |     20 |
+--------+-------+---------+------+---------------------+---------+------+--------+
5 rows in set (0.00 sec)

多行子查询

多行子查询顾名思义就是查询出来的结果有多行

  1. in关键字:查询和10号部门的工作岗位相同的雇员的名字,岗位,工资,部门号,但是不包含10自己的

首先先找到与10号部门的工作岗位,查询结果是多行的

mysql> select job from emp where deptno=10;
+-----------+
| job       |
+-----------+
| MANAGER   |
| PRESIDENT |
| CLERK     |
+-----------+
3 rows in set (0.00 sec)

再根据多行信息进行子查询

mysql> select ename,job,sal,deptno from emp where job in(select job from emp where deptno=10) and deptno<>10;
+-------+---------+---------+--------+
| ename | job     | sal     | deptno |
+-------+---------+---------+--------+
| SMITH | CLERK   |  800.00 |     20 |
| JONES | MANAGER | 2975.00 |     20 |
| BLAKE | MANAGER | 2850.00 |     30 |
| ADAMS | CLERK   | 1100.00 |     20 |
| JAMES | CLERK   |  950.00 |     30 |
+-------+---------+---------+--------+
5 rows in set (0.00 sec)
  1. all关键字;显示工资比部门30的所有员工的工资高的员工的姓名、工资和部门号

先找到部门是30的所有工资

mysql> select distinct sal from emp where deptno = 30;
+---------+
| sal     |
+---------+
| 1600.00 |
| 1250.00 |
| 2850.00 |
| 1500.00 |
|  950.00 |
+---------+
5 rows in set (0.00 sec)

再根据查询到的多行信息进行子查询

mysql> select ename,sal,deptno from emp where sal > all (select distinct sal from emp where deptno = 30);
+-------+---------+--------+
| ename | sal     | deptno |
+-------+---------+--------+
| JONES | 2975.00 |     20 |
| SCOTT | 3000.00 |     20 |
| KING  | 5000.00 |     10 |
| FORD  | 3000.00 |     20 |
+-------+---------+--------+
4 rows in set (0.00 sec)
  1. any关键字;显示工资比部门30的任意员工的工资高的员工的姓名、工资和部门号(包含自己部门的员工)

这里要理解这个任意的意思,任意员工并不是指所有的员工,而是说只要有比所有员工中的其中一个高就行了。
先找到部门是30的所有工资

mysql> select distinct sal from emp where deptno = 30;
+---------+
| sal     |
+---------+
| 1600.00 |
| 1250.00 |
| 2850.00 |
| 1500.00 |
|  950.00 |
+---------+
5 rows in set (0.00 sec)

再根据查询到的多行信息进行子查询

mysql> select ename,sal,deptno from emp where sal > any (select distinct sal from emp where deptno = 30);
+--------+---------+--------+
| ename  | sal     | deptno |
+--------+---------+--------+
| ALLEN  | 1600.00 |     30 |
| WARD   | 1250.00 |     30 |
| JONES  | 2975.00 |     20 |
| MARTIN | 1250.00 |     30 |
| BLAKE  | 2850.00 |     30 |
| CLARK  | 2450.00 |     10 |
| SCOTT  | 3000.00 |     20 |
| KING   | 5000.00 |     10 |
| TURNER | 1500.00 |     30 |
| ADAMS  | 1100.00 |     20 |
| FORD   | 3000.00 |     20 |
| MILLER | 1300.00 |     10 |
+--------+---------+--------+
12 rows in set (0.00 sec)

多列子查询

单行子查询是指子查询只返回单列,单行数据;多行子查询是指返回单列多行数据,都是针对单列而言的,而多列子查询则是指查询返回多个列数据的子查询语句。

  • 查询和SMITH的部门和岗位完全相同的所有雇员,不含SMITH本人

先查询出SMITH的部门和岗位

mysql> select deptno,job from emp where ename = 'SMITH';
+--------+-------+
| deptno | job   |
+--------+-------+
|     20 | CLERK |
+--------+-------+
1 row in set (0.00 sec)

再根据查询到的多列数据进行子查询

mysql> select * from emp where (deptno, job) = (select deptno,job from emp where ename = 'SMITH') and ename != 'SMITH';
+--------+-------+-------+------+---------------------+---------+------+--------+
| empno  | ename | job   | mgr  | hiredate            | sal     | comm | deptno |
+--------+-------+-------+------+---------------------+---------+------+--------+
| 007876 | ADAMS | CLERK | 7788 | 1987-05-23 00:00:00 | 1100.00 | NULL |     20 |
+--------+-------+-------+------+---------------------+---------+------+--------+
1 row in set (0.00 sec)

如果是多列多行的话也可使用in

mysql> select * from emp where (deptno, job) in(select deptno,job from emp where ename = 'SMITH') and ename != 'SMITH';
+--------+-------+-------+------+---------------------+---------+------+--------+
| empno  | ename | job   | mgr  | hiredate            | sal     | comm | deptno |
+--------+-------+-------+------+---------------------+---------+------+--------+
| 007876 | ADAMS | CLERK | 7788 | 1987-05-23 00:00:00 | 1100.00 | NULL |     20 |
+--------+-------+-------+------+---------------------+---------+------+--------+
1 row in set (0.00 sec)

在from子句中使用子查询

在学习Linux的时候我们学习了在Linux下一切皆文件。到了MySQL这我们也有一句话就是MySQL下一切皆表,也就是说其实我们使用select查看出来的数据其实也是表,因为MySQL就是以表的形式来显示数据的。而我们也知道from是从表中拿数据的,也就是说,其实select其实也是可以写到from中的。也就是说子查询语句出现在from子句中。这里要用到数据查询的技巧,把一个子查询当做一个临时表使用。

  1. 显示每个高于自己部门平均工资的员工的姓名、部门、工资、平均工资

首先根据部门计算平均工资

mysql> select deptno,avg(sal) from emp group by deptno;
+--------+-------------+
| deptno | avg(sal)    |
+--------+-------------+
|     20 | 2175.000000 |
|     30 | 1566.666667 |
|     10 | 2916.666667 |
+--------+-------------+
3 rows in set (0.00 sec)

让这张表和emp表做笛卡尔积

这里要注意了,如果一张临时表放到from后面要去别名
mysql> select * from emp, (select deptno,avg(sal) from emp group by deptno);
ERROR 1248 (42000): Every derived table must have its own alias

mysql> select * from emp, (select deptno,avg(sal) from emp group by deptno) asal;

然后我们就得到了这张表,但是还要进处理

mysql> select ename,emp.deptno,sal,mysal from emp, (select deptno,avg(sal) mysal from emp group by deptno) asal where emp.deptno=asal.deptno;
+--------+--------+---------+-------------+
| ename  | deptno | sal     | mysal       |
+--------+--------+---------+-------------+
| SMITH  |     20 |  800.00 | 2175.000000 |
| ALLEN  |     30 | 1600.00 | 1566.666667 |
| WARD   |     30 | 1250.00 | 1566.666667 |
| JONES  |     20 | 2975.00 | 2175.000000 |
| MARTIN |     30 | 1250.00 | 1566.666667 |
| BLAKE  |     30 | 2850.00 | 1566.666667 |
| CLARK  |     10 | 2450.00 | 2916.666667 |
| SCOTT  |     20 | 3000.00 | 2175.000000 |
| KING   |     10 | 5000.00 | 2916.666667 |
| TURNER |     30 | 1500.00 | 1566.666667 |
| ADAMS  |     20 | 1100.00 | 2175.000000 |
| JAMES  |     30 |  950.00 | 1566.666667 |
| FORD   |     20 | 3000.00 | 2175.000000 |
| MILLER |     10 | 1300.00 | 2916.666667 |
+--------+--------+---------+-------------+
14 rows in set (0.00 sec)

此时我们就有了一张表,这个时候就可当作是单表查询了。

mysql> select ename,emp.deptno,sal,mysal from emp, (select deptno,avg(sal) mysal from emp group by deptno) asal where emp.deptno=asal.deptno and emp.sal > asal.mysal;
+-------+--------+---------+-------------+
| ename | deptno | sal     | mysal       |
+-------+--------+---------+-------------+
| ALLEN |     30 | 1600.00 | 1566.666667 |
| JONES |     20 | 2975.00 | 2175.000000 |
| BLAKE |     30 | 2850.00 | 1566.666667 |
| SCOTT |     20 | 3000.00 | 2175.000000 |
| KING  |     10 | 5000.00 | 2916.666667 |
| FORD  |     20 | 3000.00 | 2175.000000 |
+-------+--------+---------+-------------+
6 rows in set (0.00 sec)
  1. 查找每个部门工资最高的人的姓名、工资、部门、最高工资

先找到每个部门的最高工资

mysql> select deptno,max(sal) maxsal from emp group by deptno;
+--------+---------+
| deptno | maxsal  |
+--------+---------+
|     20 | 3000.00 |
|     30 | 2850.00 |
|     10 | 5000.00 |
+--------+---------+
3 rows in set (0.00 sec)

再与emp做笛卡尔积

mysql> select ename,sal,t1.deptno,maxsal from emp t1,(select deptno,max(sal) maxsal from emp group by deptno) t2 where t1.deptno=t2.deptno;
+--------+---------+--------+---------+
| ename  | sal     | deptno | maxsal  |
+--------+---------+--------+---------+
| SMITH  |  800.00 |     20 | 3000.00 |
| ALLEN  | 1600.00 |     30 | 2850.00 |
| WARD   | 1250.00 |     30 | 2850.00 |
| JONES  | 2975.00 |     20 | 3000.00 |
| MARTIN | 1250.00 |     30 | 2850.00 |
| BLAKE  | 2850.00 |     30 | 2850.00 |
| CLARK  | 2450.00 |     10 | 5000.00 |
| SCOTT  | 3000.00 |     20 | 3000.00 |
| KING   | 5000.00 |     10 | 5000.00 |
| TURNER | 1500.00 |     30 | 2850.00 |
| ADAMS  | 1100.00 |     20 | 3000.00 |
| JAMES  |  950.00 |     30 | 2850.00 |
| FORD   | 3000.00 |     20 | 3000.00 |
| MILLER | 1300.00 |     10 | 5000.00 |
+--------+---------+--------+---------+
14 rows in set (0.00 sec)

然后就是进行单表查询

mysql> select ename,sal,t1.deptno,maxsal from emp t1,(select deptno,max(sal) maxsal from emp group by deptno) t2 where t1.deptno=t2.deptno and t1.sal = t2.maxxsal;
+-------+---------+--------+---------+
| ename | sal     | deptno | maxsal  |
+-------+---------+--------+---------+
| BLAKE | 2850.00 |     30 | 2850.00 |
| SCOTT | 3000.00 |     20 | 3000.00 |
| KING  | 5000.00 |     10 | 5000.00 |
| FORD  | 3000.00 |     20 | 3000.00 |
+-------+---------+--------+---------+
4 rows in set (0.01 sec)
  1. 显示每个部门的信息(部门名,编号,地址)和人员数量
  • 方法1:使用多表查询
mysql> select dept.dname, dept.deptno, dept.loc,count(*) '部门人数' from emp,dept where emp.deptno=dept.deptno group by dept.deptno,dept.dname,dept.loc;
+------------+--------+----------+--------------+
| dname      | deptno | loc      | 部门人数     |
+------------+--------+----------+--------------+
| RESEARCH   |     20 | DALLAS   |            5 |
| SALES      |     30 | CHICAGO  |            6 |
| ACCOUNTING |     10 | NEW YORK |            3 |
+------------+--------+----------+--------------+
3 rows in set (0.00 sec)
  • 方法2:使用子查询
mysql> select * from dept,(select deptno,count(*) empcount from emp group by deptno) t where dept.deptno=t.deptno;
+--------+------------+----------+--------+----------+
| deptno | dname      | loc      | deptno | empcount |
+--------+------------+----------+--------+----------+
|     10 | ACCOUNTING | NEW YORK |     10 |        3 |
|     20 | RESEARCH   | DALLAS   |     20 |        5 |
|     30 | SALES      | CHICAGO  |     30 |        6 |
+--------+------------+----------+--------+----------+
3 rows in set (0.00 sec)
  • 所以处理多表问题的本质就是想办法把多表转化为单表,所以MySQL中,所有select问题全部都可以转化为单表问题。

合并查询

在实际应用中,为了合并多个select的执行结果,可以使用集合操作符 union,union all

union

  • 将工资大于25000或职位是MANAGER的人找出来
mysql> select * from emp where sal > 2500 union
    -> select * from emp where job = 'MANAGER';
+-------+-------+-----------+------+---------------------+---------+------+--------+
| empno | ename | job       | mgr  | hiredate            | sal     | comm | deptno |
+-------+-------+-----------+------+---------------------+---------+------+--------+
|  7566 | JONES | MANAGER   | 7839 | 1981-04-02 00:00:00 | 2975.00 | NULL |     20 |
|  7698 | BLAKE | MANAGER   | 7839 | 1981-05-01 00:00:00 | 2850.00 | NULL |     30 |
|  7788 | SCOTT | ANALYST   | 7566 | 1987-04-19 00:00:00 | 3000.00 | NULL |     20 |
|  7839 | KING  | PRESIDENT | NULL | 1981-11-17 00:00:00 | 5000.00 | NULL |     10 |
|  7902 | FORD  | ANALYST   | 7566 | 1981-12-03 00:00:00 | 3000.00 | NULL |     20 |
|  7782 | CLARK | MANAGER   | 7839 | 1981-06-09 00:00:00 | 2450.00 | NULL |     10 |
+-------+-------+-----------+------+---------------------+---------+------+--------+
6 rows in set (0.00 sec)

union all

  • 将工资大于25000或职位是MANAGER的人找出来
mysql> select * from emp where sal > 2500 union all
    -> select * from emp where job = 'MANAGER';
+-------+-------+-----------+------+---------------------+---------+------+--------+
| empno | ename | job       | mgr  | hiredate            | sal     | comm | deptno |
+-------+-------+-----------+------+---------------------+---------+------+--------+
|  7566 | JONES | MANAGER   | 7839 | 1981-04-02 00:00:00 | 2975.00 | NULL |     20 |
|  7698 | BLAKE | MANAGER   | 7839 | 1981-05-01 00:00:00 | 2850.00 | NULL |     30 |
|  7788 | SCOTT | ANALYST   | 7566 | 1987-04-19 00:00:00 | 3000.00 | NULL |     20 |
|  7839 | KING  | PRESIDENT | NULL | 1981-11-17 00:00:00 | 5000.00 | NULL |     10 |
|  7902 | FORD  | ANALYST   | 7566 | 1981-12-03 00:00:00 | 3000.00 | NULL |     20 |
|  7566 | JONES | MANAGER   | 7839 | 1981-04-02 00:00:00 | 2975.00 | NULL |     20 |
|  7698 | BLAKE | MANAGER   | 7839 | 1981-05-01 00:00:00 | 2850.00 | NULL |     30 |
|  7782 | CLARK | MANAGER   | 7839 | 1981-06-09 00:00:00 | 2450.00 | NULL |     10 |
+-------+-------+-----------+------+---------------------+---------+------+--------+
8 rows in set (0.00 sec)

本章节使用数据库

DROP database IF EXISTS `scott`;
CREATE database IF NOT EXISTS `scott` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_c    i;
 
USE `scott`;
 
 DROP TABLE IF EXISTS `dept`;
 CREATE TABLE `dept` (
   `deptno` int(2) unsigned zerofill NOT NULL COMMENT '部门编号',
   `dname` varchar(14) DEFAULT NULL COMMENT '部门名称',
   `loc` varchar(13) DEFAULT NULL COMMENT '部门所在地点'
 );
 
 
 DROP TABLE IF EXISTS `emp`;
 CREATE TABLE `emp` (
   `empno` int(6) unsigned zerofill NOT NULL COMMENT '雇员编号',
   `ename` varchar(10) DEFAULT NULL COMMENT '雇员姓名',
   `job` varchar(9) DEFAULT NULL COMMENT '雇员职位',
   `mgr` int(4) unsigned zerofill DEFAULT NULL COMMENT '雇员领导编号',
   `hiredate` datetime DEFAULT NULL COMMENT '雇佣时间',
   `sal` decimal(7,2) DEFAULT NULL COMMENT '工资月薪',
   `comm` decimal(7,2) DEFAULT NULL COMMENT '奖金',
   `deptno` int(2) unsigned zerofill DEFAULT NULL COMMENT '部门编号'
 );
 
 DROP TABLE IF EXISTS `salgrade`;
 CREATE TABLE `salgrade` (
   `grade` int(11) DEFAULT NULL COMMENT '等级',
   `losal` int(11) DEFAULT NULL COMMENT '此等级最低工资',
   `hisal` int(11) DEFAULT NULL COMMENT '此等级最高工资'
 );
 
 insert into dept (deptno, dname, loc)
 values (10, 'ACCOUNTING', 'NEW YORK');
 insert into dept (deptno, dname, loc)
 values (20, 'RESEARCH', 'DALLAS');
 insert into dept (deptno, dname, loc)                                                  
 values (30, 'SALES', 'CHICAGO');
 insert into dept (deptno, dname, loc)
 values (40, 'OPERATIONS', 'BOSTON');
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7369, 'SMITH', 'CLERK', 7902, '1980-12-17', 800, null, 20);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7499, 'ALLEN', 'SALESMAN', 7698, '1981-02-20', 1600, 300, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7521, 'WARD', 'SALESMAN', 7698, '1981-02-22', 1250, 500, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7566, 'JONES', 'MANAGER', 7839, '1981-04-02', 2975, null, 20);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7654, 'MARTIN', 'SALESMAN', 7698, '1981-09-28', 1250, 1400, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7698, 'BLAKE', 'MANAGER', 7839, '1981-05-01', 2850, null, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7782, 'CLARK', 'MANAGER', 7839, '1981-06-09', 2450, null, 10);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7788, 'SCOTT', 'ANALYST', 7566, '1987-04-19', 3000, null, 20);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7839, 'KING', 'PRESIDENT', null, '1981-11-17', 5000, null, 10);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7844, 'TURNER', 'SALESMAN', 7698,'1981-09-08', 1500, 0, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7876, 'ADAMS', 'CLERK', 7788, '1987-05-23', 1100, null, 20);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7900, 'JAMES', 'CLERK', 7698, '1981-12-03', 950, null, 30);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7902, 'FORD', 'ANALYST', 7566, '1981-12-03', 3000, null, 20);
 
 insert into emp (empno, ename, job, mgr, hiredate, sal, comm, deptno)
 values (7934, 'MILLER', 'CLERK', 7782, '1982-01-23', 1300, null, 10);
 
 insert into salgrade (grade, losal, hisal) values (1, 700, 1200);
 insert into salgrade (grade, losal, hisal) values (2, 1201, 1400);
 insert into salgrade (grade, losal, hisal) values (3, 1401, 2000);
 insert into salgrade (grade, losal, hisal) values (4, 2001, 3000);
 insert into salgrade (grade, losal, hisal) values (5, 3001, 9999);