sql / expert
Snippet
Row Value Constructors for Multi-Column Comparison
Row Value Constructors (Tuples) allow you to compare multiple values simultaneously. This is more concise than using multiple AND/OR conditions and allows the engine to optimize multi-column filtering logic using a single composite expression.
snippet.sql
1
2
3
SELECT *FROM project_tasksWHERE (priority, status) IN ((1, 'OPEN'), (2, 'IN_PROGRESS'));
Breakdown
1
(priority, status)
Creates a row-level tuple consisting of two specific columns.
2
IN ((1, 'OPEN'), ...)
Evaluates the row tuple against a set of predefined constant tuples.