List the columns that specific tables have in common - Amazon Athena
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

List the columns that specific tables have in common

You can list the columns that specific tables in a database have in common.

  • Use the syntax SELECT column_name FROM information_schema.columns.

  • For the WHERE clause, use the syntax WHERE table_name IN ('table1', 'table2').

Example – Listing common columns for two tables in the same database

The following example query lists the columns that the tables table1 and table2 have in common.

SELECT column_name FROM information_schema.columns WHERE table_name IN ('table1', 'table2') GROUP BY column_name HAVING COUNT(*) > 1;