Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: Select a-row alternative from several tables one-by-one until found

Re: Select a-row alternative from several tables one-by-one until found

From: Dirk Sudheimer <sudheimer_at_gmx.de>
Date: 2000/05/30
Message-ID: <39336b52.0@juno.wiesbaden.netsurf.de>#1/1

On Tue, 30 May 2000 11:12:04 +0800, Rayfil Cheung <rayfil_at_forward-hk.com> wrote:

>Hi friend,
>
>Thank you for your advice. Sorry for my vague mind. The searched
>value(row) may be stored in one or many tables. The searched tables are
>given the priority. Once the value(row) is found, no further tables are
>needed to be searched.
>
>Thanks & Regards,
>Rayfil.
>

Hi Rayfil,
maybe the following approach works for you:

SELECT somefield, 1 FROM TableWithHighestPriority UNION
SELECT somefield, 2 FROM TableWithSecondHighestPriority UNION
...
SELECT somefield, n FROM TableWithLeastPriority SORT BY 2 and just use the first row returned (of course all tables are searched, but at least you get the values from the table with the highest priority).

Dirk Received on Tue May 30 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US