从多条记录提取数据的一个问题,我想了2天也没想出来!求助!
两个表:1---------------------------------------------
create table Department (
dpt_no number(2)
constraint pk_department PRIMARY KEY,
dpt_name varchar2(25)
constraint nn_dpt_name NOT NULL,
mgr_ssn char(9),
mgr_start_date date
);
2----------------------------------------------
create table Employee (
emp_ssn char(9)
constraint pk_employee PRIMARY KEY,
emp_last_name varchar2(25)
constraint nn_emp_last_name NOT NULL,
emp_first_name varchar2(25)
constraint nn_emp_first_name NOT NULL,
emp_birth_date date,
emp_address varchar2(50),
emp_sex char(1),
emp_salary number(7,2),
emp_superssn char(9),
emp_dpt_no number(2),
CONSTRAINT fk_emp_superssn FOREIGN KEY (emp_superssn)
REFERENCES employee
ON DELETE SET NULL,
CONSTRAINT fk_emp_dpt_no FOREIGN KEY (emp_dpt_no)
REFERENCES department
ON DELETE SET NULL
);
=================================================
值:
=========================================================
insert into Department
values ('3','Research',NULL,NULL);
insert into Department
values ('5','Design',NULL,NULL);
....................
insert into Department_locations
values ('3','Mout');
insert into Department_locations
values ('5','Meadow');
....................
insert into Project
values ('01','Strom','Mout','3');
insert into Project
values ('02','Wind','Mout','3');
insert into Project
values ('03','CBS','Mout','5');
--------------------------------------------------------------------
insert into employee
values ('420124', 'Green', 'Jim', '05/JUN/82', '23-1 Park St.', 'M','75000',NULL, '3');
insert into employee
values ('420123', 'Brodoloi', 'Elsa', '12/SEP/81', '24-2 King St.', 'F','45000', '420124', '3');
insert into employee
values ('420122', 'Queen', 'Sonia', '15/DEC/80', '12 Church St.', 'F','50000', '420124', '3');
insert into employee
values ('420121', 'King', 'Albert', '25/JUN/77', '45 Beach St.', 'M','52000', '420124', '3');
insert into employee
values ('420125', 'Davi', 'Jeffery', '23/DEC/79', '12-1 Queen St.', 'M','65000', NULL, '5');
insert into employee
values ('420126', 'Green', 'Austin', '04/AUG/78', '11 Princess St.', 'M','55000', '420125', '5');
insert into employee
values ('420127', 'Win', 'Angus', '22/AUG/83', '08 Robson St.', 'M','52000', '420125', '5');
...................
问题:
查找那些在2个或多个部门工作的员工的姓名!
在此求助,大家帮帮忙!
!