Query grammar reference

The table below contains a complete Search Ads 360 Query Language grammar reference.

Grammar reference
Query
SELECT clause
SELECT FIELD_NAME (, FIELD_NAME)*
FROM clause
FROM RESOURCE_NAME
WHERE clause
WHERE CONDITION (AND CONDITION)*
ORDER BY clause
ORDER BY ORDERING (, ORDERING)*
LIMIT clause
LIMIT POSITIVE_INTEGER
PARAMETERS clause
PARAMETERS LITERAL = VALUE (, LITERAL = VALUE)*
Field name
[a-z] ([a-zA-Z0-9._])*
Resource name
[a-z] ([a-zA-Z_])*
Condition FIELD_NAME OPERATOR VALUE
Ordering
FIELD_NAME (ASC | DESC)?
Operator
= | != | > | >= | < | <= | IN | NOT IN | LIKE | NOT LIKE | CONTAINS ANY |
CONTAINS ALL | CONTAINS NONE | IS NULL | IS NOT NULL | DURING | BETWEEN |
REGEXP_MATCH | NOT REGEXP_MATCH
Function
LAST_14_DAYS | LAST_30_DAYS | LAST_7_DAYS | LAST_BUSINESS_WEEK | LAST_MONTH |
LAST_WEEK_MON_SUN | LAST_WEEK_SUN_SAT | THIS_MONTH | THIS_WEEK_MON_TODAY |
THIS_WEEK_SUN_TODAY | TODAY | YESTERDAY
Value
LITERAL | LITERAL_LIST | NUMBER | NUMBER_LIST | STRING | STRING_LIST | FUNCTION
Positive integer
[1-9] ([0-9])*
Number
-? [0-9]+ (. [0-9] [0-9]*)?
String
(' Char* ') | (" Char* ")
Literal
[a-zA-Z0-9_]*
String list
( STRING (, STRING)* )
Literal list
( LITERAL (, LITERAL)* )
Number list
( NUMBER (, NUMBER)* )

Key:

  • ? indicates an optional element.
  • * means zero or more
  • + means one or more.
  • (xxxxxx) indicates a grouping.
  • [a-z0-9] indicates a character range.
  • Char indicates any character.
  • | stands for "or".
  • The REGEXP_MATCH operator uses RE2 syntax.
  • To match a [, ], %, or _ literal using the LIKE operator, surround the character in square brackets. For example, the following condition matches all campaign.name values that start with [Earth_to_Mars]:

    WHERE campaign.name LIKE '[[]Earth[_]to[_]Mars[]]%'