Junior — Middle
Can you explain the purpose and use of the WHERE operator in SQL queries?
sobes.tech AI
Answer from AI
The WHERE operator in SQL is used to filter rows in a query based on a specified condition. It allows selecting only those records from a table that meet certain criteria.
For example, if there is a table Employees, and you want to select employees with a salary greater than 50,000, the query would be:
SELECT * FROM Employees WHERE Salary > 50000;
WHERE can be used with various comparison operators (=, >, <, LIKE, IN, etc.) and logical operators (AND, OR, NOT) to build complex conditions.
Thus, WHERE limits the dataset returned by the query, making the selection more precise and efficient.