Solved

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

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
All XML, All the Time; More Fun MySQL Tidbits – Dynamically Generate XML via Stored Procedure in MySQL Extensible Markup Language (XML) and database systems, a marriage we are seeing more and more of.  So the topics of parsing and manipulating XM…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

708 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

13 Experts available now in Live!

Get 1:1 Help Now