← All lessons/Querying with SaQL
12
Querying with SaQL

All 15 WhereOp Operators

Every comparison operator available in SaQL filter expressions.

Prerequisite: Lesson 11 complete

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)
Challenge

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

OperatorMeaningExample value
eqEqual"pro"
neNot equal"free"
gtGreater than100
ltLess than500
gteGreater than or equal0
lteLess than or equal999
betweenInclusive range[10, 50]
containsSubstring match"@gmail"
starts_withPrefix match"usr_"
ends_withSuffix match".com"
likeSQL-style wildcard (%, _)"usr_%"
inValue in list["free", "starter"]
is_nullField is null or missing*(no value needed)*
is_not_nullField is present and not null*(no value needed)*
ftsFull-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".

---

← Previous
Lesson 11: SaQL Basics
Next →
Lesson 13: Compound Filters (AND / OR / NOT)