10 KiB
Comparison operators evaluate the relationship between the left and right
operands and returns true
or false
.
Operator | Meaning | |
---|---|---|
= |
Equal to | {{< icon "link" >}} |
<> |
Not equal to | {{< icon "link" >}} |
!= |
Not equal to | {{< icon "link" >}} |
> |
Greater than | {{< icon "link" >}} |
>= |
Greater than or equal to | {{< icon "link" >}} |
< |
Less than | {{< icon "link" >}} |
<= |
Less than or equal to | {{< icon "link" >}} |
IS DISTINCT FROM |
Is distinct from | {{< icon "link" >}} |
IS NOT DISTINCT FROM |
Is not distinct from | {{< icon "link" >}} |
~ |
Matches a regular expression | {{< icon "link" >}} |
~* |
Matches a regular expression (case-insensitive) | {{< icon "link" >}} |
!~ |
Does not match a regular expression | {{< icon "link" >}} |
!~* |
Does not match a regular expression (case-insensitive) | {{< icon "link" >}} |
=
The =
operator compares the left and right operands and, if equal, returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 123 = 123
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(123) = Int64(123) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
!=, <>
The !=
and <>
operators compare the left and right operands and, if not equal,
returns true
. Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 123 != 456
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(123) != Int64(456) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 123 <> 456
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(123) != Int64(456) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
>
The >
operator compares the left and right operands and, if the left operand
is greater than the right operand, returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 3 > 2
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(3) > Int64(2) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
>=
The >=
operator compares the left and right operands and, if the left operand
is greater than or equal to the right operand, returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 3 >= 2
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(3) >= Int64(2) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
<
The <
operator compares the left and right operands and, if the left operand
is less than the right operand, returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 1 < 2
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int641(1) < Int64(2) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
<=
The <=
operator compares the left and right operands and, if the left operand
is less than or equal to the right operand, returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 1 <= 2
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int641(1) <= Int64(2) |
---|
true |
{{% /flex-content %}} {{< /flex >}}
IS DISTINCT FROM
The IS DISTINCT FROM
operator is a NULL-safe operator that returns
true
if both operands are not equal; otherwise, it returns false
.
This operator guarantees the result of a comparison is true
or false
and not
an empty set.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 0 IS DISTINCT FROM NULL
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Int64(0) IS DISTINCT FROM NULL |
---|
true |
{{% /flex-content %}} {{< /flex >}}
IS NOT DISTINCT FROM
The IS NOT DISTINCT FROM
operator is a NULL-safe operator that returns
true
if both operands are equal or NULL; otherwise, it returns false
.
This operator negates IS DISTINCT FROM
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT NULL IS NOT DISTINCT FROM NULL
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
NULL IS NOT DISTINCT FROM NULL |
---|
true |
{{% /flex-content %}} {{< /flex >}}
~
The ~
operator compares the left string operand to the right regular expression
operand and, if it matches (case-sensitive), returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 'abc' ~ 'a.*'
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Utf8("abc") ~ Utf8("a.*") |
---|
true |
{{% /flex-content %}} {{< /flex >}}
~*
The ~*
operator compares the left string operand to the right regular expression
operand and, if it matches (case-insensitive), returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 'Abc' ~* 'A.*'
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Utf8("Abc") ~* Utf8("A.*") |
---|
true |
{{% /flex-content %}} {{< /flex >}}
!~
The !~
operator compares the left string operand to the right regular expression
operand and, if it does not match (case-sensitive), returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 'abc' !~ 'd.*'
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Utf8("abc") !~ Utf8("d.*") |
---|
true |
{{% /flex-content %}} {{< /flex >}}
!~*
The !~*
operator compares the left string operand to the right regular expression
operand and, if it does not match (case-insensitive), returns true
.
Otherwise returns false
.
{{< flex >}} {{% flex-content "two-thirds operator-example" %}}
SELECT 'Abc' !~* 'a.*'
{{% /flex-content %}} {{% flex-content "third operator-example" %}}
Utf8("Abc") !~* Utf8("a.*") |
---|
false |
{{% /flex-content %}} {{< /flex >}}