thats effectively an OR statement, isnt it?
how would i select the itemsIDs that have all the requested colors?
for example if data was:
id : colorID : itemID
-----------------------------
1 1 1
2 1 2
3 1 3
4 2 1
5 2 4
and i want the ones that are of color 1 AND 2 i should get back
itemID
1
(since its the only one with both specified colors)
----- Original Message -----
From: "Fred Whipple" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, June 12, 2003 2:47 PM
Subject: Re: again with SELECT
> danchik wrote:
> > coming back to my earlier question but much more simplified portion of
it :)
> >
> >
> > I the following table :
> >
> > theTable
> > -----------------------
> > ID | int (key)
> > colorID | int
> > itemID | int
> > -----------------------
> >
> > how do I select all itemIDs that have colorID = 1 and colorID = 2 and
> > colorID = 3 ... and colorID = N ?
>
> I didn't read the previous version of your question, but is the set of
> 'n' color ID's known at query time? If so,
>
> SELECT ID FROM theTable WHERE colorID in {1, 2, 3, 4, ..., n}
>
> Or if you want say a range where colorID is between 5 and 10,
>
> SELECT ID FROM theTable WHERE colorID >= 5 AND colorID <= 10
>
> -Fred
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
http://lists.mysql.com/[EMAIL PROTECTED]
>
>
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]