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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Problem: invite SQL...

Re: Problem: invite SQL...

From: Jack Ploeg <jploeg_at_wxs.nl>
Date: 9 Jul 1998 14:35:01 GMT
Message-ID: <01bdab46$bc182000$7086ea9e@NL0544.europe.logica.com>


Dmitry,

This select statment gives you your output:

SELECT f.FoodID, f.FoodName, decode(a.FoodID,null,'FALSE',TRUE') FROM Food f, Ate a
WHERE Food.FoodID = Ate.FoodID(+);

Dmitry M.Ivlev <Dimon_at_Diogen.nstu.nsk.su> wrote in article <6o215o$8up$1_at_nic.nstu.nsk.su>...
> Hi!
>
> I have not much experience to use SQL. I want invite SQL described below
> under Oracle and can't imagine how. I have two tables (foods and what
person
> ate):
> CREATE Food(FoodID INTEGER, FoodName CHAR(20))
> INSERT INTO T1 VALUES (1, 'Fish')
> INSERT INTO T1 VALUES (2, 'Milk')
> INSERT INTO T1 VALUES (3, 'Pie')
> INSERT INTO T1 VALUES (4, 'Meat')
>
> CREATE Ate(FoodID INTEGER, PersonName CHAR(20))
> INSERT INTO T2 VALUES (1, 'Mishel')
> INSERT INTO T2 VALUES (2, 'Mishel')
> INSERT INTO T2 VALUES (3, 'Mishel')
> INSERT INTO T2 VALUES (1, 'Dmitry')
> INSERT INTO T2 VALUES (4, 'Dmitry')
>
> Now how can I select (for given person) all foods plus one boolean field
> which has true if persone ate this kind of food:
> RESULT for Dmitry must be:
> 1 Fish TRUE
> 2 Milk FALSE
> 3 Pie FALSE
> 3 Meat TRUE
>
> for Mishel it gives:
> 1 Fish TRUE
> 2 Milk TRUE
> 3 Pie TRUE
> 3 Meat FALSE
>
> How can I do it making ONW QUERY?
>
> Dmitry.
> email: Dimon_at_Diogen.nstu.nsk.su
>
>
>
>
>
Received on Thu Jul 09 1998 - 09:35:01 CDT

Original text of this message

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