On Wed, 2010-06-16 at 08:59 +0100, Nigel Wood wrote: > I'd use: > drop temporary table if exists AttSearchMatches; > select pid as targetPid, count(*) as criteraMatched from B where > userId=35 and ( (b.aid=1 and b.value >50) OR (b.aid=3 and b.value > =4) ) group by pid having criteraMatched = 2; > drop temporary table if exists AttSearchMatches; > select <fields you want> from criteraMatched cm on cm. inner join A on > a.pid=criteraMatched.pid; > drop temporary table AttSearchMatches;
Nope :-) Without the silly errors I'd use: drop temporary table if exists AttSearchMatches; select pid, count(*) as criteraMatched from B where b.userId=35 and ( (b.aid=1 and b.value >50) OR (b.aid=3 and b.value =4) ) group by b.pid having criteraMatched = 2; select a.<fields you want> from AttSearchMatches asm inner join A on a.pid=asm.pid; drop temporary table AttSearchMatches; Sorry, Nigel -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org