DEV Community

Ezhil Abinaya K
Ezhil Abinaya K

Posted on

Postgresql Operators

Greater Than
The > operator is used when you want to return all records where a columns is greater than a specified value.

SELECT * FROM cars
WHERE year > 1975;
Enter fullscreen mode Exit fullscreen mode

Less Than or Equal To
The <= operator is used when you want to return all records where a column is less than, or equal to, a specified value.

SELECT * FROM cars
WHERE year <= 1975;
Enter fullscreen mode Exit fullscreen mode

Greater Than or Equal to
The >= operator is used when you want to return all records where a columns is greater than, or equal to, a specified value.

SELECT * FROM cars
WHERE year >= 1975;
Enter fullscreen mode Exit fullscreen mode

LIKE
The LIKE operator is used when you want to return all records where a column is equal to a specified pattern.The pattern can be an absolute value like 'Volvo', or with a wildcard that has a special meaning.
There are two wildcards often used in conjunction with the LIKE operator:

  • The percent sign %, represents zero, one, or multiple characters.
  • The underscore sign _, represents one single character. Return all records where the model STARTS with a capital 'M':
SELECT * FROM cars
WHERE model LIKE 'M%';
Enter fullscreen mode Exit fullscreen mode

Reference
https://www.w3schools.com/postgresql/postgresql_operators.php

Top comments (0)