Reputation: 11
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!
Upvotes: 1
Views: 455
Reputation: 10232
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")
Upvotes: 3