Junior — Middle
Can the WHERE operator be used when performing JOIN in SQL queries?
sobes.tech AI
Answer from AI
Yes, the WHERE operator can be used when performing a JOIN in SQL queries. Typically, JOIN is used to combine tables based on a specific condition, and WHERE is used to filter the final data set after the join.
Example:
SELECT employees.name, departments.name
FROM employees
JOIN departments ON employees.department_id = departments.id
WHERE departments.name = 'Sales';
In this example, the tables employees and departments are first joined on department_id, and then filtered by department name using WHERE.