I think you need something like:
select name from table where id = 5
intersect
select name from table where id = 11
EXCEPT I dont know of a DB that does intersect :( Only ever union.
I'm sure I'm wrong, but I dont know if it _can_ be done at all.
N
[EMAIL PROTECTED] wrote:
>
> nope,
>
> that would look for single records where the attributeID = 5 and = 11 etc. That
> is impossible so it would return an empty set.
>
> Stacey Verner <[EMAIL PROTECTED]> on 03/11/99 15:36:23
>
> Please respond to [EMAIL PROTECTED]
>
> To: Multiple recipients of list database <[EMAIL PROTECTED]>
> cc: (bcc: Phillip Middlemiss/NZ Forest Research Institute/NZ)
>
> Subject: RE: [DUG-DB]: A tricky SQL problem
>
> Isn't is just as follows where you need to produce a where clause and
> for each attribute_id?
>
> select name from example
> where attribute_id = 5
> and attribute_id = 11
> and attribute_id = ??
>
> Stacey Verner Ph: +64-9-4154790
> Software Developer Fax: +64-9-4154791
> CJN Technologies Ltd. Email: [EMAIL PROTECTED]
>
> PO Box 302-278, North Harbour, Auckland, New Zealand
> 12 Piermark Drive, North Harbour Estate, Auckland, NZ
> Visit our website at http://www.cjntech.co.nz/
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [SMTP:[EMAIL PROTECTED]]
> > Sent: Thursday, November 04, 1999 10:20 AM
> > To: Multiple recipients of list database
> > Subject: [DUG-DB]: A tricky SQL problem
> >
> >
> >
> > Hi, I have a tricky SQL problem (you may have guessed that from the
> > subject
> > heading :) that is beyond my SQL ability. And it only involves one
> > table.
> >
> > Here is a simplified example table:
> >
> > Name AttributeID
> >
> > Bob 5
> > Bob 3
> > Bob 11
> > Jim 5
> > Jim 7
> > Alice 8
> > Alice 5
> > Alice 11
> >
> > Basically, a person can have any number of attribute ID's (possibly
> > even the
> > same one twice). The query goes something like this: "Find me all the
> > names that
> > have records for AttributeID 5 and for AttributeID 11" where the 5 and
> > the 11
> > will change depending on what the user is searching for. The example
> > query only
> > required 2 attributeID's to exist, but there is in fact no limit.
> >
> > I'm guessing that some kind of tricky sub-query or exists clause is
> > needed but
> > every time I try and formulate it it escapes me.
> >
> > Phil.
> >
> >
> > ----------------------------------------------------------------------
> > -----
> > New Zealand Delphi Users group - Database List -
> > [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> ---------------------------------------------------------------------------
> New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
>
> ---------------------------------------------------------------------------
> New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
--
Nic Wise - Inprise New Zealand / Brocker Technologies Web Monkey.
mob:+64.21.676.418 - wk:+64.9.481.9999 x9753 - wk-em:[EMAIL PROTECTED]
hm: +64.9.277.5309 - hm-em:[EMAIL PROTECTED]
---------------------------------------------------------------------------
New Zealand Delphi Users group - Database List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz