当前位置:网站首页>Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name

Database SQL practice 4. Find the last of employees in all assigned departments_ Name and first_ name

2022-07-05 07:12:00 Just as young

Title Description

Find all the employees in the assigned department last_name and first_name as well as dept_no( Notice the order of the columns in the output description )

CREATE TABLE `dept_emp` (
`emp_no` int(11) NOT NULL,
`dept_no` char(4) NOT NULL,
`from_date` date NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`dept_no`));
CREATE TABLE `employees` (
`emp_no` int(11) NOT NULL,
`birth_date` date NOT NULL,
`first_name` varchar(14) NOT NULL,
`last_name` varchar(16) NOT NULL,
`gender` char(1) NOT NULL,
`hire_date` date NOT NULL,
PRIMARY KEY (`emp_no`));

Input description :

 nothing 

Output description :

last_namefirst_namedept_no
FacelloGeorgid001
Omit Omit Omit
PiveteauDuangkaewd006

Implementation code

select e.last_name, e.first_name, d.dept_no
from employees as e 
inner join dept_emp as d
on e.emp_no = d.emp_no
原网站

版权声明
本文为[Just as young]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140559380294.html