That returns rows that have any of 'A01', 'B02'. I need the rows that have
all of them. E.g. logical OR vs. logical AND.
----- Original Message ----- 
From: "Shane Allen" <[EMAIL PROTECTED]>
To: "Jonathan Terhorst" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Monday, November 10, 2003 8:26 PM
Subject: Re: Maybe easy, maybe hard SELECT puzzle :)


> At 07:45 PM 11/7/2003, Jonathan Terhorst wrote:
> >  <snip>
> >One way I have found to implement this is
> >SELECT Table1.id from Table1 JOIN Features USING(id) WHERE
> >Features.FeatureCode='A01' OR Features.FeatureCode='B02' GROUP BY
Table1.id
> >HAVING COUNT(*)=2;
> >
> >e.g. counting the duplications of id and selecting those equal to the
number
> >of FeatureCodes I'm searching for. But this seems somehow inelegant, and
I'm
> >justing wondering if there's a better way that's staring me in the face.
>
> SELECT DISTINCT f.id FROM Table1 AS t, Features AS f
> WHERE f.id = t.id AND f.FeatureCode IN ('A01', 'B02');
>
> HTH
>
>
> mysql, query, sql
>
>
>
> -- 
> 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]

Reply via email to