All 15 WhereOp Operators
Every comparison operator available in SaQL filter expressions.
What you'll learn
- ✓Equality: eq, ne
- ✓Numeric: gt, lt, gte, lte, between
- ✓String: contains, starts_with, ends_with, like (%/_)
- ✓Set: in (list of values)
- ✓Null: is_null, is_not_null
- ✓Text search: fts (full-text)
Use between to find orders where amount is 50–200. Use starts_with to find orders where status starts with 'ship'.
Interactive Walkthrough
What you'll learn
Every comparison operator available in SaQL filter expressions.
The full operator list
| Operator | Meaning | Example value |
|---|---|---|
eq | Equal | "pro" |
ne | Not equal | "free" |
gt | Greater than | 100 |
lt | Less than | 500 |
gte | Greater than or equal | 0 |
lte | Less than or equal | 999 |
between | Inclusive range | [10, 50] |
contains | Substring match | "@gmail" |
starts_with | Prefix match | "usr_" |
ends_with | Suffix match | ".com" |
like | SQL-style wildcard (%, _) | "usr_%" |
in | Value in list | ["free", "starter"] |
is_null | Field is null or missing | *(no value needed)* |
is_not_null | Field is present and not null | *(no value needed)* |
fts | Full-text search | "database agent" |
Examples
`bash
# between
curl -s -X POST http://localhost:7475/v1/agents/orders/query \
-H "Content-Type: application/json" \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
-d '{"type":"scan","limit":50,"filter":{"field":"amount","op":"between","value":[100,500]}}' \
| python3 -m json.tool
# in curl -s -X POST http://localhost:7475/v1/agents/users/query \ -H "Content-Type: application/json" \ -H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \ -d '{"type":"scan","limit":50,"filter":{"field":"plan","op":"in","value":["pro","enterprise"]}}' \ | python3 -m json.tool
# starts_with curl -s -X POST http://localhost:7475/v1/agents/users/query \ -H "Content-Type: application/json" \ -H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \ -d '{"type":"scan","limit":50,"filter":{"field":"user_id","op":"starts_with","value":"usr_"}}' \ | python3 -m json.tool
# is_null — find records where 'phone' field is missing
curl -s -X POST http://localhost:7475/v1/agents/users/query \
-H "Content-Type: application/json" \
-H "Authorization: Bearer spx_root_YOUR_ROOT_KEY" \
-d '{"type":"scan","limit":50,"filter":{"field":"phone","op":"is_null"}}' \
| python3 -m json.tool
`
Challenge
Using the orders agent, find all orders where amount > 50 AND amount < 200 using between. Then find orders where status starts with "ship".
---