题目:中等题

CREATE TABLE `salaries` (
`emp_no` int(11) NOT NULL,
`salary` int(11) NOT NULL,
`from_date` date NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`from_date`));
CREATE TABLE `dept_manager` (
`dept_no` char(4) NOT NULL,
`emp_no` int(11) NOT NULL,
`to_date` date NOT NULL,
PRIMARY KEY (`emp_no`,`dept_no`));

代码:

方法一:

select s.*,d.dept_no
from salaries as s,dept_manager as d
where s.emp_no=d.emp_no

方法二:

select s.*,d.dept_no
from salaries s
right join dept_manager d
on s.emp_no=d.emp_no

不知道为什么题目要求排序输出,我没有进行排序能对,知道为什么的大佬们可以给我留个言,感谢。