mysql need to use COUNT (group function) within WHERE clause

willsherwood
willsherwood used Ask the Experts™
on
here's a simplified case that does not work - it is dumbed-down to have a simple
form that shows the error:   invalid use of group function

select ID from tblMembers where count(ID=177)=1

how can i include an "insulated"  COUNT  within  a where clause?
is there a way to make a sub-query?

the actual usage is in the context:

    SELECT ....  FROM tblA, tblB WHERE  tblA.stuff=$C1   AND   COUNT( tblB.stuff=$C1 ) =0

tblA and tblB are unrelated,  unrelational.   i just need them to be within a single query due to the called context of a single shell command.

thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
how about
 SELECT ....  FROM tblA WHERE  tblA.stuff=$C1   AND
    $C1 = (select  COUNT( tblB.stuff) from tblb)

Author

Commented:
this gives me a syntax that i think i can adapt to get the desired behavior.
thanks for the structural tip !

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial