Re: [SQL] Tricky -to me!- SQL query. - Mailing list pgsql-sql

From Remigiusz Sokolowski
Subject Re: [SQL] Tricky -to me!- SQL query.
Date
Msg-id Pine.GS4.4.02A.9901121442100.7827-100000@netra.gdansk.sprint.pl
Whole thread Raw
In response to Re: [SQL] Tricky -to me!- SQL query.  (stuart@ludwig.ucl.ac.uk (Stuart Rison))
List pgsql-sql
> >
> >What about:
> >SELECT person FROM test WHERE fruit='pears' AND fruit='apples' AND
> >fruit='oranges';
> >or just
> >SELECT person FROM test WHERE fruit IN ('pears', 'apples','oranges');
> >
> >For me strange question - so I think I don't mean exactly what you do ;-)
>
> Hello Rem,
>
> Yes, there is a misunderstanding here, sorry about that, could be my posting.
> The first solution would return an empty table because there are no cases
> where fruit can be equal to two different things (the data in fruit are
> atomic so the field fruit can only ever be equal to one thing).
>
> The second of solutions answers the question "Who eats pears or eats apples
> or eats oranges?" but not the question "Who eats pears AND apples AND
> oranges?" (i.e. it would give the answers lucy, peter and stuart when the
> actual answers should be lucy and peter because, in the example table,
> stuart does not eat oranges).
>
Oh, no... I apologize for that - is here to hot or smth.
I must be ill - when I wrote fruit='smth' and fruit='smth_else' - it
couldn't be solution for that.
You're absolutely right.
It needs nested queries or function(which also should realize some
queries)
    Rem

-------------------------------------------------------------------*------------
Remigiusz Sokolowski      e-mail: rems@gdansk.sprint.pl           * *
-----------------------------------------------------------------*****----------


pgsql-sql by date:

Previous
From: stuart@ludwig.ucl.ac.uk (Stuart Rison)
Date:
Subject: Re: [SQL] Tricky -to me!- SQL query.
Next
From: "Neil Burrows"
Date:
Subject: A path through a tree