SQL - Comparison Operators
Here are the comparison operators in SQL Server:
Equal to (=): Checks if two values are equal.
Example:
SELECT * FROM Customers WHERE City = 'New York';
Not equal to (<> or !=): Checks if two values are not equal.
Example:
SELECT * FROM Customers WHERE City <> 'London';
Greater than (>): Checks if the left operand is greater than the right operand.
Example:
SELECT * FROM Orders WHERE OrderAmount > 1000;
Less than (<): Checks if the left operand is less than the right operand.
Example:
SELECT * FROM Products WHERE UnitPrice < 10.00;
Greater than or equal to (>=): Checks if the left operand is greater than or equal to the right operand.
Example:
SELECT * FROM Employees WHERE Age >= 30;
Less than or equal to (<=): Checks if the left operand is less than or equal to the right operand.
Example:
SELECT * FROM Customers WHERE RegistrationDate <= '2022-01-01';
These comparison operators are commonly used in SELECT statements, WHERE clauses, JOIN conditions, and other SQL operations to compare values and conditions to filter and retrieve data based on specific criteria.