گرامر زبان جستجوی تبلیغات گوگل
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
ondemand_video ویدیو: اعتبارسنجی کوئری ها
در اینجا مرجع دستور زبان Google Ads Query Language (در نماد عبارت منظم) آمده است:
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
?
یک عنصر اختیاری را نشان می دهد
*
به معنای صفر یا بیشتر است. +
به معنای یک یا چند است
(xxxxxx)
یک گروه بندی را نشان می دهد
[a-z0-9]
نشان دهنده محدوده کاراکترها است
|
مخفف "یا"
قوانین و محدودیت ها
عملگر REGEXP_MATCH
از نحو RE2 استفاده می کند.
برای تطبیق [
, ]
, %
, یا _
با استفاده از عملگر LIKE
، دور کاراکتر را در پرانتز قرار دهید. برای مثال، شرط زیر با تمام مقادیر campaign.name
که با [Earth_to_Mars]
شروع میشوند مطابقت دارد:
campaign.name LIKE '[[]Earth[_]to[_]Mars[]]%'
عملگر LIKE
فقط می توان در یک فیلد رشته ای استفاده کرد، نه یک آرایه.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-26 بهوقت ساعت هماهنگ جهانی."],[[["\u003cp\u003eGoogle Ads Query Language (GAQL) uses a specific syntax to construct queries for retrieving data from Google Ads accounts, similar to SQL.\u003c/p\u003e\n"],["\u003cp\u003eGAQL supports various clauses like \u003ccode\u003eSELECT\u003c/code\u003e, \u003ccode\u003eFROM\u003c/code\u003e, \u003ccode\u003eWHERE\u003c/code\u003e, \u003ccode\u003eORDER BY\u003c/code\u003e, \u003ccode\u003eLIMIT\u003c/code\u003e, and \u003ccode\u003ePARAMETERS\u003c/code\u003e for data manipulation.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eWHERE\u003c/code\u003e clause allows filtering data based on conditions using operators like \u003ccode\u003e=\u003c/code\u003e, \u003ccode\u003e!=\u003c/code\u003e, \u003ccode\u003e>\u003c/code\u003e, \u003ccode\u003e<\u003c/code\u003e, \u003ccode\u003eIN\u003c/code\u003e, \u003ccode\u003eLIKE\u003c/code\u003e, \u003ccode\u003eCONTAINS\u003c/code\u003e, and others.\u003c/p\u003e\n"],["\u003cp\u003eGAQL provides built-in functions such as \u003ccode\u003eLAST_14_DAYS\u003c/code\u003e, \u003ccode\u003eTHIS_MONTH\u003c/code\u003e, \u003ccode\u003eTODAY\u003c/code\u003e, etc., for convenient date range selection within queries.\u003c/p\u003e\n"],["\u003cp\u003eWhen using operators like \u003ccode\u003eLIKE\u003c/code\u003e, special characters need to be escaped with square brackets for literal matching.\u003c/p\u003e\n"]]],[],null,["# Google Ads Query Language Grammar\n\nondemand_video\n[Video: Validating Queries](https://www.youtube.com/watch?v=pBpFEaXvADY&list=None&start=11)\n\nHere is the Google Ads Query Language grammar reference (in regular expression notation): \n\n```googlesql\nQuery -\u003e SelectClause FromClause WhereClause? OrderByClause?\n LimitClause? ParametersClause?\nSelectClause -\u003e SELECT FieldName (, FieldName)*\nFromClause -\u003e FROM ResourceName\nWhereClause -\u003e WHERE Condition (AND Condition)*\nOrderByClause -\u003e ORDER BY Ordering (, Ordering)*\nLimitClause -\u003e LIMIT PositiveInteger\nParametersClause -\u003e PARAMETERS Literal = Value (, Literal = Value)*\n\nCondition -\u003e FieldName Operator Value\nOperator -\u003e = | != | \u003e | \u003e= | \u003c | \u003c= | IN | NOT IN |\n LIKE | NOT LIKE | CONTAINS ANY | CONTAINS ALL |\n CONTAINS NONE | IS NULL | IS NOT NULL | DURING |\n BETWEEN | REGEXP_MATCH | NOT REGEXP_MATCH\nValue -\u003e Literal | LiteralList | Number | NumberList | String |\n StringList | Function\nOrdering -\u003e FieldName (ASC | DESC)?\n\nFieldName -\u003e [a-z] ([a-zA-Z0-9._])*\nResourceName -\u003e [a-z] ([a-zA-Z_])*\n\nStringList -\u003e ( String (, String)* )\nLiteralList -\u003e ( Literal (, Literal)* )\nNumberList -\u003e ( Number (, Number)* )\n\nPositiveInteger -\u003e [1-9] ([0-9])*\nNumber -\u003e -? [0-9]+ (. [0-9] [0-9]*)?\nString -\u003e (' Char* ') | (\" Char* \")\nLiteral -\u003e [a-zA-Z0-9_]*\n\nFunction -\u003e LAST_14_DAYS | LAST_30_DAYS | LAST_7_DAYS |\n LAST_BUSINESS_WEEK | LAST_MONTH | LAST_WEEK_MON_SUN |\n LAST_WEEK_SUN_SAT | THIS_MONTH | THIS_WEEK_MON_TODAY |\n THIS_WEEK_SUN_TODAY | TODAY | YESTERDAY\n```\n\n`?`indicates an optional element \n\n`*` means zero or more; `+` means one or more \n\n`(xxxxxx)` indicates a grouping \n\n`[a-z0-9]` signifies character ranges \n\n`|` stands for \"or\"\n\nRules and limitations\n---------------------\n\n- The `REGEXP_MATCH` operator uses [RE2\n syntax](//github.com/google/re2/wiki/Syntax).\n\n- To match a literal `[`, `]`, `%`, or `_` using the `LIKE` operator, surround\n the character in square brackets. For example, the following condition matches\n all `campaign.name` values that start with `[Earth_to_Mars]`:\n\n campaign.name LIKE '[[]Earth[_]to[_]Mars[]]%'\n\n- The `LIKE` operator can only be used on a string field, not an array."]]