SELECT
t2.id,
(SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10)
AS t4_num
FROM
t2
WHERE
t2.active
AND (
(SELECT COUNT(id) FROM t4 WHERE t2_id = t2.id AND value=10) <= 3
)
select
t2.id, count( t4.id)
from
t2 join t4 using on (t2.id=t4.t2_id)
where
t2.active and t4.value < 10
group by t2.id
having count(t4.id) <= 3
should do the trick without double select, or?
Harald
--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!