Junior — Middle
Can you explain how to use the WHERE clause in SQL queries for data filtering?
sobes.tech AI
Answer from AI
The WHERE operator in SQL is used to filter rows returned by a query. It sets a condition, and only records that meet this condition will be included in the result.
For example, if you have a table Employees and want to get all employees from the "Sales" department, the query would be:
SELECT * FROM Employees WHERE Department = 'Sales';
Here, WHERE Department = 'Sales' restricts the selection to only those rows where the value of the Department column is "Sales".
You can use different comparison operators (=, >, <, LIKE, IN, etc.) and logical operators (AND, OR, NOT) to create complex conditions.