Google-sheets – Trying to query a range of names in Google Spreadsheets, query is failing with the space in the names

google sheets

I'm trying to query a range of names in Google Spreadsheets. When I try and make a query like: =QUERY('QA Import'!A1:H, "select A where G = "&B2&"") where B2 is John Doe I get the error

Unable to parse query string for Function QUERY parameter 2: PARSE_ERROREncountered "Doe" at line 1, column 27. Was expecting one of: "group" … "pivot" … "order" … "skipping" … "limit" … "offset" … "label" … "format" … "options" … "and" … "or" … "*" … "+" … "-" … "/" … "%" …

How do I make a query that includes data with spaces?

Best Answer

Enclose the string value (John Doe) between single quotes ('John Doe'). The resulting formula is:

=QUERY('QA Import'!A1:H, "select A where G = '"&B2&"'")

References