SQL Tutorial SQL Advanced SQL Database SQL References

SQL - Greater than or equal to (>=) Operator



The SQL >= (greater than or equal to) operator checks if the value of left operand is greater than or equal to the value of right operand and returns true if the condition is true, false otherwise.

The example below describes how to use this operator in various conditions:

Example:

Consider a database table called Employee with the following records:

EmpIDNameCityAgeSalary
1JohnLondon253000
2MarryNew York242750
3JoParis272800
4KimAmsterdam303100
5RameshNew Delhi283000
6HuangBeijing282800

  • Using with WHERE Clause: To select records of table where Age of the person is greater than or equal to 27, the SQL code is given below.

    SELECT * FROM Employee
    WHERE Age >= 27;
    

    The query will produce following result:

    EmpIDNameCityAgeSalary
    3JoParis272800
    4KimAmsterdam303100
    5RameshNew Delhi283000
    6HuangBeijing282800
  • Using with AS Clause: If the above condition is used with AS clause, it will produce a column having boolean result, 1 if the condition is true and 0 if the condition is false. See the example below:

    SELECT *, (Age >= 27) AS Result FROM Employee;
    

    The above query will produce following result:

    EmpIDNameCityAgeSalaryResult
    1JohnLondon2530000
    2MarryNew York2427500
    3JoParis2728001
    4KimAmsterdam3031001
    5RameshNew Delhi2830001
    6HuangBeijing2828001
  • Using with UPDATE Clause: The operator can also be used to update a column with boolean result, 1 if the condition is true and 0 if the condition is false. See the example query below:

    UPDATE Employee
    SET Age = (Age >= 27);
    
    --See result
    SELECT * FROM Employee
    

    The query will produce following result:

    EmpIDNameCityAgeSalary
    1JohnLondon03000
    2MarryNew York02750
    3JoParis12800
    4KimAmsterdam13100
    5RameshNew Delhi13000
    6HuangBeijing12800
  • Using with values: A condition can be checked simply by using SELECT statement:

    SELECT 50 >= 25
    

    The query will produce following result:

    50 >= 25
    1

❮ SQL Operators

5