Open History to see the last commit
1---
2id: unionWherePredicates
3title: unionWherePredicates
4---
5
6# Function: unionWherePredicates()
7
8```ts
9function unionWherePredicates(predicates): BasicExpression<boolean>;
10```
11
12Defined in: [packages/db/src/query/predicate-utils.ts:328](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L328)
13
14Combine multiple where predicates with OR logic (union).
15Returns a predicate that is satisfied when any input predicate is satisfied.
16Simplifies when possible (e.g., age > 10 OR age > 20 → age > 10).
17
18## Parameters
19
20### predicates
21
22[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md)\<`boolean`\>[]
23
24Array of where predicates to union
25
26## Returns
27
28[`BasicExpression`](../@tanstack/namespaces/IR/type-aliases/BasicExpression.md)\<`boolean`\>
29
30Combined predicate representing the union
31
32## Examples
33
34```ts
35// Take least restrictive
36unionWherePredicates([gt(ref('age'), val(10)), gt(ref('age'), val(20))]) // age > 10
37```
38
39```ts
40// Combine equals into IN
41unionWherePredicates([eq(ref('age'), val(5)), eq(ref('age'), val(10))]) // age IN [5, 10]
42```