Help Center > > Developer Guide> SQL Reference> Functions and Operators> Logical Operators

Logical Operators

Updated at: Jul 15, 2020 GMT+08:00

The usual logical operators include AND, OR, and NOT. SQL uses a three-valued logical system with true, false, and null, which represents "unknown". Their priorities are NOT > AND > OR.

Table 1 lists operation rules, where a and b represent logical expressions.

Table 1 Operation rules

a

b

a AND b Result

a OR b Result

NOT a Result

TRUE

TRUE

TRUE

TRUE

FALSE

TRUE

FALSE

FALSE

TRUE

FALSE

TRUE

NULL

NULL

TRUE

FALSE

FALSE

FALSE

FALSE

FALSE

TRUE

FALSE

NULL

FALSE

NULL

TRUE

NULL

NULL

NULL

NULL

NULL

The operators AND and OR are commutative, that is, you can switch the left and right operand without affecting the result.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel