[thelist] SQL question
Joshua Olson
joshua at waetech.com
Thu Aug 22 19:03:01 CDT 2002
----- Original Message -----
From: "rudy" <r937 at interlog.com>
To: <thelist at lists.evolt.org>
Subject: Re: [thelist] SQL question
> > That unfortunately translates to conditions where s.www_id is
> > either 2 OR 4. Note the "OR"... it should be "AND".
>
> lauri, what you want requires grouping
>
> not sure why you were saying comp_id=1
>
> the following works for any comp_id, and returns only those that have both
> www_id=2 and www_id-4
>
> select first.comp_id
> from first
> inner join second
> on first.comp_id = second.comp_id
> and www_id in (2,4)
> group by first.comp_id
> having count(*)=2
>
> whaddya know, works in mysql too ;o)
Rudy, I hate to contradict you (since you are the man, and all), but
wouldn't that query also return comp_id's from table "first" if table
"second" had two rows with www_id = 2 for a particular comp_id?
-joshua
;-)
More information about the thelist
mailing list