SQL Comparison operators | SQL Tutorial and Query Example

Text copied!

SQL Comparison operators


  • Overview of SQL comparison operators :
    1. Equal to :

    It is a operator denoted by equal to (=) symbol and use to check if two values are matching.

    2. Not equal to :

    It is a operator denoted by either the (<>) or (!=) symbols and use to check if two values are not matching.

    3. Greater than :

    It is a operator denoted by (>) symbol and use to check if a value is greater than other values.

    • Equal to   =
    • Not equal to   <> or !=
    • Greater than   >
    • Less than   <
    • Greater than or equal to   >=
    • Less than or equal to   <=
            
    4. Less than :

    It is a operator denoted by (<) symbol and use to check if a value is less than other values.

    SQL Comparison operators
    5. Greater than or equal to :

    It is a operator denoted by (>=) symbol and use to check if a value is greater than or equal to other values.

    6. Less than or equal to :

    It is a operator denoted by (>=) symbol and use to check if a value is less than or equal to other values.

    SELECT *
    FROM [Employees]
    WHERE Employee_Id = 3;
            
    SQL Comparison operators
    To enhance your understanding of 'SQL operators', be sure to check out our next tutorial.
    SELECT *
    FROM [Employees]
    WHERE Gender != 'Male';
            
    SQL Comparison operators
    SELECT *
    FROM [Employees]
    WHERE Salary > 4000;
            
    SQL Comparison operators
    SELECT *
    FROM [Employees]
    WHERE Salary < 3000;
            
    SQL Comparison operators
    SELECT *
    FROM [Employees]
    WHERE Salary >= 4000;
            
    SQL Comparison operators
    SELECT *
    FROM [Employees]
    WHERE Salary <= 2000;
            
    SQL Comparison operators

    Frequently Asked Questions :

    Comparison operators in SQL include "=", "<>", ">", "<", ">=", and "<=".
    The six comparison operators are "=", "<>", ">", "<", ">=", and "<=".
    In SQL Server, you use "=" instead of "==" for comparison.
    Comparison operators in SQL include "=", "<>", ">", "<", ">=", and "<=".