Logical disjunction operator OR

Last updated: 2026-11-04

Logical disjunction operator OR

OR joins two boolean conditions and yields true when either side is true. It also follows three-valued logic: true OR NULL is true (already decided), while false OR NULL is NULL (cannot be decided). WHERE still keeps only rows whose result is true.

Kindoperator
Example LanguageSQL

📝 Syntax

a OR b

Precedence: `OR` is the lowest-precedence logical operator, sitting just above parentheses. `a = 1 OR b = 2 AND c = 3` parses as `a = 1 OR (b = 2 AND c = 3)` because AND binds tighter. Use parentheses to make grouping explicit in complex conditions. Like AND, OR is commutative, but the left operand is not guaranteed to be evaluated first.

⚙️ Parameters

aLeft boolean condition; participates under three-valued logic when NULL.
bRight boolean condition; participates under three-valued logic when NULL.

Returns:The boolean true, false, or NULL when both operands are NULL or combine false with NULL.

▶ Example

Runs real PostgreSQL 18 right in your browser (PGlite WASM, nothing to install). Press ▶ Run and the result appears in the panel below.

Output:

SELECT id, a, b, a OR b AS or_result FROM t_or ORDER BY id
id | a     | b     | or_result
---+-------+-------+----------
 1 | true  | true  | true     
 2 | true  | false | true     
 3 | false | NULL  | NULL     
 4 | true  | NULL  | true     
 5 | NULL  | NULL  | NULL     
(5 rows)

SELECT a OR b IS NULL AS result_is_null FROM t_or WHERE id = 3
result_is_null
--------------
true          
(1 row)

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QIs FALSE OR NULL false?
ANo, it is NULL. "False or unknown" can be neither confirmed true nor confirmed false, so the result is unknown.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏