Esta es la referencia gramatical del lenguaje de consulta de Google Ads (en notación de expresiones regulares):
Query -> SelectClause FromClause WhereClause? OrderByClause? LimitClause? ParametersClause? SelectClause -> SELECT FieldName (, FieldName)* FromClause -> FROM ResourceName WhereClause -> WHERE Condition (AND Condition)* OrderByClause -> ORDER BY Ordering (, Ordering)* LimitClause -> LIMIT PositiveInteger ParametersClause -> PARAMETERS Literal = Value (, Literal = Value)* Condition -> FieldName Operator Value 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 Value -> Literal | LiteralList | Number | NumberList | String | StringList | Function Ordering -> FieldName (ASC | DESC)? FieldName -> [a-z] ([a-zA-Z0-9._])* ResourceName -> [a-z] ([a-zA-Z_])* StringList -> ( String (, String)* ) LiteralList -> ( Literal (, Literal)* ) NumberList -> ( Number (, Number)* ) PositiveInteger -> [1-9] ([0-9])* Number -> -? [0-9]+ (. [0-9] [0-9]*)? String -> (' Char* ') | (" Char* ") Literal -> [a-zA-Z0-9_]* 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
?
indica un elemento opcional.
*
significa cero o más; +
significa uno o más
(xxxxxx)
indica una agrupación
[a-z0-9]
significa los rangos de caracteres
|
significa "o"
Reglas y limitaciones
El operador
REGEXP_MATCH
usa RE2 sintaxis.Para hacer coincidir un
[
,]
,%
o_
literal con el operadorLIKE
, enciérralos el carácter entre corchetes. Por ejemplo, la siguiente condición coincide todos los valorescampaign.name
que comienzan con[Earth_to_Mars]
:campaign.name LIKE '[[]Earth[_]to[_]Mars[]]%'
El operador
LIKE
solo se puede usar en un campo de cadena, no en un array.