Operators combine values: they add, compare, match patterns and join conditions. This page lists the common ones with a real example each, and the precedence table that decides which operator is applied first. For explanations, see SQL Operators and AND, OR and NOT.
Arithmetic Operators
Operator
Meaning
Example
Result
+
Add
2 + 3
5
-
Subtract
7 - 2
5
*
Multiply
4 * 3
12
/
Divide (integers give an integer in PostgreSQL)
7 / 2
3
%
Remainder
7 % 2
1
^
Power (PostgreSQL)
2 ^ 10
1024
Comparison Operators
Operator
Meaning
Example
Result
=
Equal
1 = 1
true
<> or !=
Not equal
1 <> 2
true
<, >, <=, >=
Less, greater
2 >= 2
true
IS DISTINCT FROM
Not equal, treating NULLs as comparable
NULL IS DISTINCT FROM 1
true
Logical Operators
Operator
Meaning
Example
Result
AND
Both true
true AND false
false
OR
At least one true
true OR false
true
NOT
Negate
NOT true
false
Pattern and Range Operators
Operator
Meaning
Example
Result
LIKE
Pattern with % and _
'Navika' LIKE 'Nav%'
true
ILIKE
Case-insensitive LIKE (PostgreSQL)
'Navika' ILIKE 'nav%'
true
BETWEEN
Inclusive range
5 BETWEEN 1 AND 5
true
IN
In a list
'CA' IN ('CA', 'TX')
true
~
Regular expression match (PostgreSQL)
'2025-12-03' ~ '^\d{4}'
true
Text Operators
Operator
Meaning
Example
Result
||
Join text
'Nav' || 'ika'
Navika
Sets and Subqueries Operators
Operator
Meaning
Example
Result
EXISTS
Subquery returns a row
EXISTS (SELECT 1)
true
ANY / SOME
True for at least one value
3 > ANY (ARRAY[1, 5])
true
ALL
True for every value
3 > ALL (ARRAY[1, 5])
false
Check the Examples
Every result in the tables above comes from this query:
SELECT2+3AS c1,7-2AS c2,4*3AS c3,7/2AS c4,7%2AS c5,2^10AS c6,1=1AS c7,1<>2AS c8,2>=2AS c9,NULLISDISTINCTFROM1AS c10,trueANDfalseAS c11,trueORfalseAS c12,NOTtrueAS c13,'Navika'LIKE'Nav%'AS c14,'Navika' ILIKE 'nav%'AS c15,5BETWEEN1AND5AS c16,'CA'IN ('CA', 'TX') AS c17,'2025-12-03'~'^\d{4}'AS c18,'Nav'||'ika'AS c19,EXISTS (SELECT1) AS c20,3>ANY (ARRAY[1, 5]) AS c21,3>ALL (ARRAY[1, 5]) AS c22;
Output
c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c9 | c10 | c11 | c12 | c13 | c14 | c15 | c16 | c17 | c18 | c19 | c20 | c21 | c22----+----+----+----+----+------+----+----+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--------+-----+-----+----- 5 | 5 | 12 | 3 | 1 | 1024 | t | t | t | t | f | t | f | t | t | t | t | t | Navika | t | t | f(1 row)
Precedence
Operators higher in this list are applied first (PostgreSQL's order; other databases are very similar). When in doubt, use parentheses: they make the intent clear to readers too.