Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Two Counts In One Query?
- Good Man
June 17, 2005, 2:21 pm
rate this thread
I'm wrapping up my first *really* big, complex web application, and in
doing so, I realize that my next tast will be reading some SQL books and
learning how to improve my querying. I really didn't know that i could
work math equations, comparisons, and if clauses right in the statements
Anyways, I digress. I'm looking for a way to query the following... I have
a database full of people, where the Membership field is either a '1' or
'0'. I'd like to get the total counts for both situations in one query.
Something that will give me:
RegisteredMembers | 332
UnregisteredMember | 543
I can obviously get this result using two queries:
SELECT COUNT(*) AS RegisteredMembers FROM Contacts WHERE Membership='1'
SELECT COUNT(*) AS UnRegisteredMembers FROM Contacts WHERE Membership='0'
but can I do this in one query?
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum