Skip site navigation (1) Skip section navigation (2)

Finding all References to a Primary Key

From: "Matthew T(dot) O'Connor" <matthew(at)zeut(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Finding all References to a Primary Key
Date: 2008-03-26 18:19:30
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
I'm sorry if this is has been discussed, but I tried to find the answer 
in the archives and failed, so...

How do I find all the rows in other tables that reference a specific row 
in another table?  I'm only trying to find rows that are in tables where 
there is a Foreign Key referencing the primary key of the table in question.

Table People has a primary key of people_id
There are say 20 tables that have foreign keys referencing people.people_id
How do I find all the rows in all of those 20 tables that reference a 
particular person in the people table?

Thank you in advance,

Matthew O'Connor


pgsql-sql by date

Next:From: Tom LaneDate: 2008-03-26 19:26:31
Subject: Re: Bizarre sort order
Previous:From: Tom LaneDate: 2008-03-26 18:14:35
Subject: Re: FW: Re: Part 1 of several - Converting a varchar to an interval

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group