Re: simple sql question

From: Anders Altberg (x_pragma_at_telia.com)
Date: 05/05/04


Date: Wed, 5 May 2004 15:02:22 +0200

SELECT reader FROM BooksRead WHERE book in ('A','B') ;
GROUP BY reader HAVING COUNT(DISTINCT Book)>=2

-Anders

"toylet" <toylet@mail.hongkong.com> wrote in message
news:slrnc9hg3t.hbp.toylet@server.donkeyware.org...
> given this table booksread:
>
> reader title
> ------ -----
> 001 A
> 002 B
> 001 B
> 003 C
> 004 A
>
> I want to list the readers that read titles "A" and "B".
> Any better solution than the following query?
>
> select distinct reader
> from booksread
> where reader in
> ( select reader from booksread where title="A")
> and reader in
> ( select reader from booksread where title="B")
>
> --
> .~. Might, Courage, Vision. In Linux We Trust.
> / v \ http://www.linux-sxs.org
> /( _ )\ Linux 2.4.26
> ^ ^ 6:18pm up 4 days 19:41 load average: 1.02 1.01 0.98