Learn SQL Lesson
FROM and JOIN Build the Rows First
The first big step is `FROM` plus `JOIN`. SQL first decides which tables participate and how their rows connect.
Only after the joined row set exists does `WHERE` filter it.
That is why a query like this works:
SELECT e.name AS employee_name, d.name AS department_name
FROM employees AS e
JOIN departments AS d
ON e.department_id = d.id
WHERE d.name = 'Engineering'
The `WHERE` clause can filter on department data because the `JOIN` has already happened logically.
Practice challenge
Return the Engineering employees after joining employees and departments. Show employee_name and department_name, ordered by employee_name.