From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | anisoptera <dragonfly(at)elseworld(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: query for all values linked to a field |
Date: | 2011-12-13 20:51:24 |
Message-ID: | CAHyXU0wStRB9YybrQD9Ovt57s1guAxWn8mMCqV_Psi2JkLyR=w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Dec 13, 2011 at 2:37 PM, anisoptera <dragonfly(at)elseworld(dot)com> wrote:
> hi,
>
> i'm trying to output all values that can be reached from a specific record
> by a foreign key link.
>
> for example, if tblimage has image_id, image_info and tblstack has
> stack_id=tblimage.image_id, stack_info_1, stack_info_2
> i want to be able to get image_id, image_info, stack_info_1, stack_info_2.
>
> of course, my database has many more tables and links. i can use
> information_schema to get the links and recursively troll through all the
> tables, i was just wondering if there's a way to do this with one query
> instead of programmatically.
I didn't quite parse that. Using recursive queries, it should be
able to pretty easily query out, given a table name, all tables that
link to that table and the columns of the keys in the constraints
(and, if necessary, the links from other tables to those tables).
If I was looking for specific *records*, not tables and columns, I
would probably be generating a query from the above. (If I'm
understanding you properly that is).
merlin
From | Date | Subject | |
---|---|---|---|
Next Message | anisoptera | 2011-12-13 21:03:01 | Re: query for all values linked to a field |
Previous Message | anisoptera | 2011-12-13 20:37:57 | query for all values linked to a field |