SELECT employees.first_name, departments.department_name FROM employees INNER JOIN departments ON employees.department_id = departments.department_id;
This query will retrieve the “first_name” column from the “employees” table and the “department_name” column from the “departments” table. It will only include rows where the department ID matches between the two tables.
Combining Conditions with AND and OR
You can use the AND and OR operators to combine multiple conditions in the WHERE clause. For example:
SELECT * FROM employees WHERE department = 'IT' AND salary > 50000;
This query will retrieve all columns from the “employees” table where the department is ‘IT’ and the salary is greater than 50000.