Introduction
We use comparison operators to check if values are equal, bigger, smaller, or different. This helps us find or filter data in a database.
We use comparison operators to check if values are equal, bigger, smaller, or different. This helps us find or filter data in a database.
value1 = value2 value1 <> value2 value1 != value2 value1 > value2 value1 < value2 value1 >= value2 value1 <= value2
= means equal to.
<> and != both mean not equal to.
SELECT * FROM employees WHERE age = 25;
SELECT * FROM products WHERE price > 50;
SELECT * FROM orders WHERE status <> 'shipped';
SELECT * FROM users WHERE signup_date <= '2023-01-01';
This creates a table of employees, adds three people, then selects those who are 30 or older.
CREATE TABLE employees (id SERIAL PRIMARY KEY, name TEXT, age INT); INSERT INTO employees (name, age) VALUES ('Alice', 30), ('Bob', 25), ('Carol', 35); SELECT name FROM employees WHERE age >= 30;
Use = for exact matches, and <, >, <=, >= for range checks.
Both <> and != mean 'not equal' and can be used interchangeably.
Comparison operators work with numbers, text, dates, and more.
Comparison operators help filter data by comparing values.
= means equal, <> or != means not equal.
<, >, <=, >= check if values are smaller, bigger, or equal.
age is greater than or equal to 18 in PostgreSQL?products with a column price, what will the following query return?SELECT * FROM products WHERE price < 50;
SELECT * FROM users WHERE age <> 30 AND age != 25;
employees whose salary is between 3000 and 7000 inclusive. Which of the following WHERE clauses correctly uses standard comparison operators to achieve this?Pass the test and this pattern moves unknown