Skip to content

Instantly share code, notes, and snippets.

@ramiroaznar
Last active May 11, 2017 13:50
Show Gist options
  • Save ramiroaznar/9d521807f14b47af2beff9afef7e9a5c to your computer and use it in GitHub Desktop.
Save ramiroaznar/9d521807f14b47af2beff9afef7e9a5c to your computer and use it in GitHub Desktop.
Check common columns in two tables in PostgreSQL
with a as (
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'world_borders'
),
b as (
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'populated_places'
)
select a.column_name, b.column_name as other from a, b
where a.column_name = b.column_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment