# Syntax error: Unexpected identifier > BigQuery says "Unexpected identifier" when a word turns up where a statement had to start. The position in the message is the word it choked on, which is usually one token after the real mistake. Source: https://docs.querylab.io/bigquery-errors/syntax-error-unexpected-identifier/ Updated: 2026-10-25 ```text Syntax error: Unexpected identifier "sselect" at [1:1] ``` ## The fix Look one token to the left of the position in the message. In almost every case the real problem is there: a missing comma, a missing semicolon, or a keyword spelled wrong so that the parser read it as an alias. ## What BigQuery means A word appeared where a statement had to start. BigQuery has a separate message, `Expected end of input but got identifier "x"`, for a word that turns up in the middle of an otherwise complete statement. Which of the two you get tells you where the parser was when it gave up: | Message | Where the parser was | | ---------------------------------------------- | --------------------------------------------------------------------- | | `Unexpected identifier "x" at [L:C]` | at the start of a statement, waiting for `SELECT`, `WITH`, `INSERT` … | | `Expected end of input but got identifier "x"` | it had already parsed a whole statement and found more text after it | The second one is more common. `[L:C]` points at the first token the parser could not use. The actual mistake is normally one token earlier. ## Where it comes from **A typo in the leading keyword.** ```sql sselect 1 ``` **Pasted code that is not SQL.** Any language whose first word is an identifier lands here: ```sql const x = 1; ``` ```text Syntax error: Unexpected identifier "const" at [1:1] ``` A pasted Markdown code fence gives the same error with an empty name, because the three backticks are read as an empty quoted identifier. `import` is a special case with its own message, because `IMPORT` is a real GoogleSQL keyword. See [Expected keyword MODULE or keyword PROTO](https://docs.querylab.io/bigquery-errors/expected-keyword-module-or-keyword-proto/). **A missing comma in the select list.** BigQuery read `a b` as `a AS b`, then found a third name with nothing to attach it to: ```sql SELECT a b c FROM (SELECT 1 a, 2 b, 3 c) ``` ```text Syntax error: Expected end of input but got identifier "c" at [1:12] ``` **A misspelled keyword.** `WEHRE` became an alias for the table, and then `x` had no home: ```sql WITH t AS (SELECT 1 x) SELECT * FROM t WEHRE x = 1 ``` ```text Syntax error: Expected end of input but got identifier "x" at [1:46] ``` Note where the position lands. The mistake is at column 40, the message says 46. **A missing semicolon between two statements.** ```sql SELECT 1 SELECT 2 ``` ```text Syntax error: Expected end of input but got keyword SELECT at [2:1] ``` ## Things that are fine - A trailing comma before `FROM`. `SELECT 1, 2, FROM t` is valid in BigQuery. - A `#standardSQL` line at the top. It parses. - `--` and `#` and `/* */` comments. All three work. `//` does not, and gives `Syntax error: Unexpected "/"`. ## Things that are not fine - A reserved word as a bare alias. `SELECT 1 AS order` gives `Syntax error: Unexpected keyword ORDER`. Backtick it or rename it. - A dash in an identifier outside the first path part. `SELECT 1 AS my-col` gives `Syntax error: Expected end of input but got "-"`. - Smart quotes from a word processor. `Syntax error: Illegal input character "\342"`. ## In Querylab.io Querylab.io parses in the browser as you type, so these are marked before anything is sent to BigQuery, and the message names what is missing rather than the token after it. The missing comma above is reported as "Expected comma between SELECT items". ## Sources Based on the BigQuery documentation by Google, CC BY 4.0, rewritten with examples checked against BigQuery: - [Query syntax](https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax) - [Lexical structure and syntax](https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical)