Movatterモバイル変換


[0]ホーム

URL:


February 16, 2026: Out-of-cycle release scheduled for February 26, 2026
Supported Versions:Current (18) /17 /16 /15 /14
Development Versions:devel
Unsupported versions:13 /12 /11 /10 /9.6 /9.5 /9.4 /9.3 /9.2 /9.1 /9.0 /8.4 /8.3 /8.2 /8.1 /8.0 /7.4 /7.3 /7.2 /7.1
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for thecurrent version, or one of the other supported versions listed above instead.
PostgreSQL 7.2.8 Documentation
PrevChapter 4. Functions and OperatorsNext

4.2. Comparison Operators

Table 4-1. Comparison Operators

OperatorDescription
<less than
>greater than
<=less than or equal to
>=greater than or equal to
=equal
<> or!=not equal

Note: The!= operator is converted to<> in the parser stage. It is not possible to implement!= and<> operators that do different things.

Comparison operators are available for all data types where this makes sense. All comparison operators are binary operators that return values of typeboolean; expressions like1 < 2 < 3 are not valid (because there is no< operator to compare a Boolean value with3).

In addition to the comparison operators, the specialBETWEEN construct is available.

a BETWEENx ANDy

is equivalent to

a >=x ANDa <=y

Similarly,

a NOT BETWEENx ANDy

is equivalent to

a <x ORa >y

There is no difference between the two respective forms apart from theCPU cycles required to rewrite the first one into the second one internally.

To check whether a value is or is not NULL, use the constructs

expression IS NULLexpression IS NOT NULL

or the equivalent, but less standard, constructs

expression ISNULLexpression NOTNULL

Donot writeexpression = NULL because NULL is not"equal to" NULL. (NULL represents an unknown value, and it is not known whether two unknown values are equal.)

Some applications may (incorrectly) require thatexpression = NULL returns true ifexpression evaluates to the NULL value. To support these applications, the run-time optiontransform_null_equals can be turned on (e.g.,SET transform_null_equals TO ON;).PostgreSQL will then convertx = NULL clauses tox IS NULL. This was the default behavior in releases 6.5 through 7.1.

Boolean values can also be tested using the constructs

expression IS TRUEexpression IS NOT TRUEexpression IS FALSEexpression IS NOT FALSEexpression IS UNKNOWNexpression IS NOT UNKNOWN

These are similar toIS NULL in that they will always return TRUE or FALSE, never NULL, even when the operand is NULL. A NULL input is treated as the logical value UNKNOWN.


PrevHomeNext
Functions and OperatorsUpMathematical Functions and Operators

[8]ページ先頭

©2009-2026 Movatter.jp