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

How to reference 2 other pages (3 including the one I call the function on) in one query function?


This is the line of code I am trying to write:

=QUERY(Players!A:I, "select I where A = "&(Teams!A:F, "select A where F = '"&C2&"'"), 0)

Basically I am writing a query on 'Page1' that selects a name from column I on the 'Players' page where column A (also on the 'Players' page) = column A on the 'Teams' page where F = cell C2 on 'Page1'. There is a lot of referencing different pages which might make this confusing to understand. Also, the line of code is returning a formula parse error


Solution

  • try perhaps:

    =QUERY(Players!A:I, "select I where A = '"&
     QUERY(Teams!A:F,   "select A where F = '"&C2&"'", 0)&"'", 0)
    

    or:

    =QUERY(Players!A:I, "select I where A = "&
     QUERY(Teams!A:F,   "select A where F = '"&C2&"'", 0), 0)