Introduction
The WHERE clause helps you pick only the rows you want from a table by checking conditions.
The WHERE clause helps you pick only the rows you want from a table by checking conditions.
SELECT column1, column2 FROM table_name WHERE column_name comparison_operator value;
Comparison operators include =, <, >, <=, >=, and <> (not equal).
The WHERE clause filters rows before showing results.
SELECT * FROM Employees WHERE Age > 30;
SELECT Name, Price FROM Products WHERE Price <= 20;
SELECT * FROM Orders WHERE OrderDate >= '2024-01-01';
This creates a Students table, adds four students with grades, then selects those with grades less than 70.
CREATE TABLE Students ( ID INT, Name VARCHAR(50), Grade INT ); INSERT INTO Students (ID, Name, Grade) VALUES (1, 'Alice', 85), (2, 'Bob', 65), (3, 'Charlie', 70), (4, 'Diana', 90); SELECT Name, Grade FROM Students WHERE Grade < 70;
Use single quotes for text or date values in the WHERE clause.
Comparison operators work with numbers, text, and dates.
Be careful with <> which means 'not equal'.
The WHERE clause filters rows based on conditions.
Comparison operators help compare values like numbers or dates.
Use WHERE to get only the data you need from a table.
WHERE clause do in an SQL query?age is greater than 30?age > 30 is correct.Employees with columns id, name, and salary, what rows will this query return?SELECT * FROM Employees WHERE salary <= 50000;
SELECT * FROM Products WHERE price <>;
Orders table where the order_date is after January 1, 2023, and the total_amount is at least 100. Which query correctly uses WHERE with comparison operators?Pass the test and this pattern moves unknown