查询没有订单的职工姓名和职工号,写出SQL语句,并对执行结果截图
selectEmployees.Enane,EnofromEmployees,OrderswhereEmployees.Eno=Orders.EnoandEnoin(se...
select Employees.Enane,Eno from Employees,Orders
where Employees.Eno=Orders.Eno and Eno in
(select Eno from Orders where Orders.Ono is null) 展开
where Employees.Eno=Orders.Eno and Eno in
(select Eno from Orders where Orders.Ono is null) 展开
1个回答
展开全部
--建表
create table employees(eno varchar2(32), ename varchar2(32));
create table orders (orderid varchar2(32), eno varchar2(32));
--初始化基础数据
insert into employees values('1','买东西了1');
insert into employees values('11','买东西了11');
insert into employees values('111','买东西了111');
insert into employees values('1111','买东西了1111');
insert into employees values('2','没买东西2');
insert into employees values('22','没买东西22');
insert into employees values('222','没买东西222');
insert into employees values('2222','没买东西2222');
insert into orders values('1','1');
insert into orders values('11','11');
insert into orders values('111','111');
insert into orders values('1111','1111');
--查询没有订单的职工姓名和职工号
select * from employees a where not exists(select 1 from orders b where a.eno = b.eno);
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询