Comparison less-than operator <

Last updated: 2026-11-04

Comparison less-than operator <

The less-than operator < reports whether the left operand is smaller than the right, and works for numbers, text and dates. Text comparison follows the column collation and compares character by character, so uppercase letters usually sort before lowercase ones. Like every comparison operator it follows three-valued logic: a NULL operand produces NULL, and WHERE will not return that row.

Kindoperator
Example LanguageSQL

📝 Syntax

a < b

Precedence: comparison operators share one level (`< > = <= >= <>`), above `IS NULL`, above `NOT`, above `AND` and above `OR`. They do not chain, so compound conditions need parentheses or a logical operator: `a < b AND c < d` is fine, `a < b < c` is a syntax error.

⚙️ Parameters

aLeft operand; must be comparable with b.
bRight operand; must be comparable with a.

Returns:The boolean true, false, or NULL when either operand is 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, score, score < 70 AS lt_result FROM t_lt ORDER BY id
id | score | lt_result
---+-------+----------
 1 |    90 | false    
 2 |    60 | true     
 3 |  NULL | NULL     
(3 rows)

SELECT id, score FROM t_lt WHERE score < 70 ORDER BY id
id | score
---+------
 2 |    60
(1 row)

SELECT id, score IS NULL AS score_is_null FROM t_lt WHERE id = 3
id | score_is_null
---+--------------
 3 | true         
(1 row)

📌 Key Points

More case studies coming soon.

📚 Related Reference

❓ FAQ

QDoes score < 70 return rows where score is NULL?
ANo. NULL < 70 evaluates to NULL and WHERE keeps only true rows, so rows with a NULL score are filtered out.
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%

🙏 帮我们做得更好

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

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