Solved

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

Posted on 2014-02-28
2
614 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Creating and Managing Databases with phpMyAdmin in cPanel.
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

919 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now