Google Ads 查詢語言文法
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
ondemand_video
影片:驗證查詢
以下是 Google Ads 查詢語言文法參考資料 (以規則運算式標記表示):
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]
表示字元範圍
|
表示「或」
規則和限制
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-27 (世界標準時間)。
[null,null,["上次更新時間:2025-08-27 (世界標準時間)。"],[[["\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."]]