对于连接表,我总是使用以下方法:
Select e.name, e.surname, sum(s.gross) as sum_gross, AVG(s.gross) as avg_gross
from departments d
join employees e
on d.depid = e.depid
join salaries s
on e.employeeid = s.personid
group by e.name,e.surname
但现在我看到一些人以下列方式做到了这一点:
Select e.name, e.surname, sum(s.gross) as sum_gross, AVG(s.gross) as avg_gross
from departments d, employees e, salaries s
where d.depit = e.depid
and e.employeeid = s.personid
group by e.name,e.surname
我只想确保它们完全相同,哪一个是首选,是最佳做法?