The WHERE clause in SQL allows you to filter the results of a query based on specific conditions. It's how you narrow down what data you're looking for.
Let's say we have a table called 'Employees' with columns 'EmployeeID', 'FirstName', 'LastName', and 'Department'."
We want to find all employees in the 'Sales' department.
SELECT * FROM Employees WHERE Department = 'Sales';
We want to find all employees with an ID greater than 10.
SELECT * FROM Employees WHERE EmployeeID > 10;
We want to find employees who are not from New York.
SELECT * FROM Employees WHERE City != 'New York';
Find all employees with a name containing 'Smith' and a department equal to 'Marketing'."
SELECT * FROM Employees WHERE FirstName LIKE '%Smith%' AND Department = 'Marketing';
Find all employees with 'John' in their name.
SELECT * FROM Employees WHERE FirstName LIKE '%John%';