Re: Query Table Name
Date: Mon, 3 Nov 2008 13:18:32 -0800 (PST)
Message-ID: <48970c8c-7a03-4fa9-a2dc-00209b4cb001@w24g2000prd.googlegroups.com>
On Nov 3, 3:12 pm, ddf <orat..._at_msn.com> wrote:
> On Nov 3, 2:55 pm, artme..._at_gmail.com wrote:
>
> > If you are joining one or more tables, is there a way to know which
> > table the value came from? For example:
>
> > SELECT DISTINCT(id),
> > DECODE(<table_name>,value,<table_name>,value,<table_name>,value)........
> > FROM a, b, c
> > WHERE a.id = b.id
> > AND a.id = c.id;
>
> > In this same query, can I get the table name the name of the table the
> > value actually came from?
>
> I don't really understand what you've done with this ... err ....
> 'query'. Is <table_name> a stored value? Or is it your
> representation of the actual table name?
>
> You'll need to describe this 'problem' in more detail than you have to
> get any sort of usable response, I think.
>
> David Fitzjarrell
Well, I was playing around, and this mght work:
SELECT DISTINCT(customer_id), source_table
FROM
(SELECT customer_id, 'CUSTOMERS_LOOKUP' source_table
FROM customers_lookup
UNION
SELECT customer_id, 'CUSTOMERS_LOOKUP_PRIM' source_table
FROM customers_lookup_prim
UNION
SELECT customer_id, 'CUSTOMERS_LOOKUP_ZA' source_table
FROM customers_lookup_za);
So, I'll play with this for a bit........ Received on Mon Nov 03 2008 - 15:18:32 CST