1

I want to check if there is one particular field exists in different table using one query only?

For example, I have 3 tables, with many fields. I want to check if field A in table 1 exists in table 2 and table 3.

How can I do it?

Many thanks!

1 Answers1

3

You can use COLUMNS view:

SELECT *
FROM my_dataset.INFORMATION_SCHEMA.COLUMNS
WHERE column_name = "fieldA_name"
  and table_name in ("table1_name", "table2_name", "table3_name")
Sergey Geron
  • 9,098
  • 2
  • 22
  • 29