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

Home -> Community -> Usenet -> c.d.o.server -> Re: tricky SQL SELECT - help!

Re: tricky SQL SELECT - help!

From: Jaap W. van Dijk <j.w.vandijk.removethis_at_hetnet.nl>
Date: Sun, 02 Feb 2003 22:55:47 +0100
Message-ID: <vs3r3vkf0gpc0glhgbfbrr4t6f3nttjhkc@4ax.com>


On 30 Jan 2003 22:21:44 -0800, kittycatangel_at_hotmail.com (Angel Cat) wrote:

...
>Subqueries doesn't seem to allow the 'like' clause..
>
>I need a SELECT like this:
>
>SELECT ID FROM PEOPLE WHERE NAME = "JOHN" AND ID LIKE "%(SELECT
>PEOPLE_IDS FROM PETS' %"
>

...
Aside from other problems you are going to have with this interesting model:

SELECT ID FROM PEOPLE WHERE NAME = "JOHN" AND exists (select null from pets where
instr(people_ids||';',id||';')> 0)

The semicolon concatenated to people_ids is thrown in to take care that every id in the resulting string is terminated by a semicolon.

A OVERALL JOIN would look like:

select *
from people, pets
where 0 < instr(people_id||';',id||';')

A DELETE of a person

update pets
set people_ids = replace(people_ids||';', ';'||&id||':');

delete people
where id = &id;

A DELETE of a PEOPLE-PET relation occurrence:

update pets
set people_ids = replace(people_ids||';', ';'||&id||':') where pettype = &pettype;

Ensoforth.

Jaap. Received on Sun Feb 02 2003 - 15:55:47 CST

Original text of this message

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