Backticks, commas, case
BigQuery table paths often use backticks.
Backticks look like this:
`project.dataset.table`
They tell BigQuery to treat the full project, dataset, and table path as one identifier. They are especially useful when paths contain punctuation, special characters, or reserved words.
Commas also matter.
When you ask for multiple columns, separate each column with a comma:
SELECT voterbase_id, vb_vf_source_state, gender FROM `prj-training-ao7c.voterfiles.voterfile_snapshot` LIMIT 1000;
The comma tells SQL where one selected column ends and the next begins. Without commas, BigQuery may not be able to interpret the query.
Case sensitivity has a few rules:
- SQL keywords are generally not case-sensitive.
select,SELECT, andSelectcan work. - Functions like
COUNT()andAVG()are generally not case-sensitive. - Table and column identifiers are often not case-sensitive by default, but quoted identifiers and some contexts can be sensitive.
- String data is case-sensitive.
'Hello'and'hello'are different values. - For case-insensitive comparisons, analysts often use functions like
LOWER()orUPPER().
The habit to build now: write SQL keywords in uppercase, column names exactly as shown in the schema, and string values exactly as they appear in the data.
Learner action
Find three useful columns in your schema. Write them in a SELECT statement separated by commas.
Backticks : wrap the table path
BigQuery uses backticks (`) around the full project.dataset.table path. Not single quotes. Not double quotes. Backticks.
| Try this | What happens |
|---|---|
FROM `bigquery-public-data.usa_names.usa_1910_current` | Works. |
FROM 'bigquery-public-data.usa_names.usa_1910_current' | Syntax error. |
FROM "bigquery-public-data.usa_names.usa_1910_current" | Syntax error. |
FROM bigquery-public-data.usa_names.usa_1910_current | Hyphen breaks it. Error. |
If you see "Syntax error: Unexpected '.'", the first thing to check is whether your table path is wrapped in backticks. Single quotes are reserved for string values inside WHERE clauses (Module 5).
Commas : the often-overlooked superhero
From the deck (slide 34): the comma is the list delimiter in SQL. It tells the parser "another item is coming." Without it, the parser can't tell where one field ends and the next begins.
Commas in SELECT
SELECT voterbase_id, vb_vf_source_state, gender FROM `prj-training-ao7c.voterfiles.voterfile_snapshot` LIMIT 1000;
Every column except the last is followed by a comma. The last column has no trailing comma.
Commas also separate items in IN ( … ) lists, multiple columns in GROUP BY, and multiple sort fields in ORDER BY.
Case sensitivity : the one place it matters
From the deck (slide 32 speaker note):
- SQL keywords (
SELECT,FROM,WHERE) : not case-sensitive.selectandSELECTboth work. - Table and column names : also not case-sensitive by default.
- Data values inside strings : are case-sensitive.
'Hello'and'hello'are different values.
If you need to match strings without caring about case, use LOWER(column) = 'value' or UPPER(column) = 'VALUE'. You'll meet this in Module 5.
SQL is forgiving about whitespace and case for keywords : SELECT and select both work : but it's strict about commas between columns. Try writing the same query two ways.
Action: Wrap your full table path in backticks. Try writing a 3-column SELECT. Notice how BigQuery colors each piece.