I am not familiar with google sheets, but I have been sent an assignment and I don't want to take the time to convert the whole thing over to an actual database. Is a way to take one column of values (A) and another (B) and check if there is any value in A that is equal to any value in B via queries. I tried

=query(*table*, "SELECT *name of row* WHEN A=B", 1)  

but that just seems to check each row.

For you visual types, I have a database

  | A | B |
1 | 1 | 0 |
2 | 1 | 2 |
3 | 1 | 1 |
4 | 2 | 3 |

I want to select rows 2 and 3.
I didn't see a duplicate. Doesn't help how Google doesn't really document this stuff very well.


this is how you use query:

=QUERY(A1:B; "select B where A = '1'"; 0)

  • A1:B - the range you want to import
  • select B - select all columns of given range
  • where A = '1' - where in column A are cells with content 1
  • 1 - stands for 1 heading row (0 for no rows, 2 for two rows, etc.)

but maybe you seek this:

=ARRAYFORMULA(IF(A1:A=B1:B; "match"; ))

and query version would be:

=QUERY(A1:B; "select A where A=B"; 0)

  • I went ahead and converted it to a SQL database (because I know that better), but this did help me and it does work in google sheets, thanks. – orcatamer Sep 11 '18 at 17:50

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.