AND Operator
In PostgreSQL, a boolean value can have one of three values: true, false, and null.
true
true
t
true
'true'
true
'y'
true
'yes'
true
'1'
true
false
false
f
false
'false'
false
'n'
false
'no'
false
'0'
false
A boolean expression is an expression that evaluates to a boolean value. For example, the expression 1=1 is a boolean expression that evaluates to true
SELECT 1 = 1 AS result; result
--------
t
(1 row)
The letter t in the output indicates the value of true. The AND operator is a logical operator that combines two boolean expressions.
Basic PostgreSQL AND operator examples
The following example uses the
ANDoperator to combine two true values, which returns true
The following statement uses the
ANDoperator to combine true with false, which returns false
The following example uses the
ANDoperator to combine true with null, which returns null
The following example uses the
ANDoperator to combine false with false, which returns false
The following example uses the
ANDoperator to combine false with null, which returns false
Using the AND operator in the WHERE clause
The following example uses the AND operator in the WHERE clause to find the films that have a length greater than 180 and a rental rate less than 1.
Last updated