Search code examples
google-sheetsgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

How to reference two columns from two different sheets in one query


I'm trying to write a query that looks compares strings within a cell on two different pages. This is the query I have written but it says unable to parse query string because there is no column b4.

=QUERY(Teams!B:F, "select F where B = B4", 0)

Note column B is on a different page than B4.


Solution

  • if B4 is number do:

    =QUERY(Teams!B:F, "select F where B = "&B4, 0)
    

    if B4 is not number do:

    =QUERY(Teams!B:F, "select F where B = '"&B4&"'", 0)