Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-02-28
2
619 Views
Last Modified: 2014-02-28
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
0
Comment
Question by:willsherwood
2 Comments
 
LVL 19

Accepted Solution

by:
regmigrant earned 500 total points
ID: 39896424
how about
 SELECT ....  FROM tblA WHERE  tblA.stuff=$C1   AND
    $C1 = (select  COUNT( tblB.stuff) from tblb)
0
 

Author Comment

by:willsherwood
ID: 39896446
this gives me a syntax that i think i can adapt to get the desired behavior.
thanks for the structural tip !
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
I have been using r1soft Continuous Data Protection (http://www.r1soft.com/linux-cdp/) for many years now with the mySQL Addon and wanted to share a trick I have used several times. For those of us that don't have the luxury of using all transact…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question