Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Select a-row alternative from several tables one-by-one until found
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