首 页 行业热点 新车 试驾评测 养车用车 车型库

JAVA程序设计

发布网友 发布时间:2022-04-21 01:25

我来回答

6个回答

懂视网 时间:2022-05-06 17:14

增删改查 据说查询是最困难的……各种组合查询 联表查询 #0. 查询最高工资及其对应员工姓名select ename, sal from empwhere sal=(select max(sal) from emp);#如果有多个员工都是最高工资下面的方式将失效select ename, sal from emp ORDER BY sal desc lim

增删改查 据说查询是最困难的……各种组合查询 联表查询

#0. 查询最高工资及其对应员工姓名
select ename, sal from emp
where sal=(select max(sal) from emp);

#如果有多个员工都是最高工资下面的方式将失效
select ename, sal from emp ORDER BY sal desc limit 0, 1;

#补充1:能否不使用聚合函数查出最高工资及其对应员工姓名
select ename, sal from emp
where sal=(select sal from emp order by sal desc limit 0,1);

#补充2:既不用排序也不用聚合函数查出最高工资及其对应员工姓名
select ename, sal from emp
where sal not in 
(select distinct t1.sal from emp as t1
inner join emp as t2 on t1.sal(select avg(sal) from emp);

#5. 查询薪水超过其所在部门平均薪水的员工的姓名、部门名称和工资
#where写法
select ename, dname, t3.sal from
(select eno, t1.dno, sal from emp as t1,
(select dno, avg(sal) as avgSal from emp group by dno) as t2
where t1.dno=t2.dno and sal>avgSal) as t3, emp as t4, dept as t5 
where t3.eno=t4.eno and t5.dno=t3.dno;

#inner join写法
select ename, dname, t3.sal from
(select eno, t1.dno, sal from emp as t1 inner join
(select dno, avg(sal) as avgSal from emp group by dno) as t2
on t1.dno=t2.dno and sal>avgSal) as t3 inner join 
emp as t4 on t3.eno=t4.eno inner join 
dept as t5 on t5.dno=t3.dno;

#6. 查询部门中薪水最高的人姓名、工资和所在部门名称
select ename, dname, t3.sal from
(select eno, t1.dno, sal from emp as t1 inner join
(select dno, max(sal) as maxSal from emp group by dno) as t2
on t1.dno=t2.dno and sal=maxSal) as t3 inner join 
emp as t4 on t3.eno=t4.eno inner join 
dept as t5 on t5.dno=t3.dno;

#7. 哪些人是主管
select * from emp 
where eno in 
(select distinct mgr from emp);

select * from emp 
where eno=any(select distinct mgr from emp);

#补充:哪些人不是主管
select * from emp 
where eno not in (select distinct mgr from emp where mgr is not null);

#8. 求平均薪水最高的部门的名称和平均工资
select dname as 部门名称, avgSal as 平均工资 from
(select dno, avgSal
from (select dno, avg(sal) as avgSal from emp
group by dno) t1 
where avgSal=(select max(avgSal) from 
(select dno, avg(sal) as avgSal from emp group by dno) as t2)) as t3
inner join dept as t4 on t3.dno=t4.dno;

#9. 求薪水最高的前3名雇员
select * from emp order by sal desc limit 0,3;

#10.求薪水排在第4-6名雇员
select * from emp order by sal desc limit 3,3;


热心网友 时间:2022-05-06 14:22

这段代码是用来按不同分类查询图书的JFrame。

这段代码中的一些类的方法,可能在别的代码都会被使用。

构造器用来初始化图形界面。

myPanels()方法初始化三个面板,每个面板中都有一个JCheckBox和JTextField。并且给JCheckBox添加了*,使JTextField不可用。

MyItemListener是添加给JCheckBox的*,当JCheckBox被点击时,该类的itemStateChanged()方法会被调用。不过我怀疑itemStateChanged()方法中的内容有问题,因为它只对第一个JCheckBox做出了响应。

对于MyItemListener类的其它方法getAdmJpane()、myactionPerformed()在你帖的代码中没有调用过。我想你的代码中少了一个提交按钮,而点击提交按钮时应该调用myactionPerformed(),它是真正对数据库进行查询的方法。

总体来看,这段代码很垃圾。也许它可以运行,但代码逻辑很不清楚。希望你自己重写一个,也比看这段代码强。

如果想运行这段代码,而无其它代码,你需要把myactionPerformed()方法注释了,因为它包含了sqlServer类,而这段代码没有这个类。还需要把构造器中最后一句j.setVisible(false); 修改为j.setVisible(true);这样就可以运行了。

热心网友 时间:2022-05-06 15:40

好长

热心网友 时间:2022-05-06 17:15

真的好长

热心网友 时间:2022-05-06 19:06

这里没有高手,老兄,

想想别的办法吧,上帝与你同在

热心网友 时间:2022-05-06 21:14

有邮箱吗?

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com