Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6838919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:39:19+00:00 2026-05-26T23:39:19+00:00

This query doesn’t work. Can someone help me please? $query = SELECT COUNT(WHERE Name=’george’)

  • 0

This query doesn’t work. Can someone help me please?

$query = "SELECT 
    COUNT(WHERE Name='george') AS george_total,
    COUNT(WHERE Name='michael') AS michael_total,
    COUNT(WHERE Name='mike') AS mike_total 
FROM users WHERE Banned IS NOT '1' AND Active='yes' AND Logins>1 AND Registered_to_forum='1'";

$row=mysql_fetch_array($result);
echo "
    We found $row['george_total'] people with the name 'George' in our database,
    $row['michael_total'] with the name Michael
    and $row['mike_total'] with the name Mike.
";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:39:20+00:00Added an answer on May 26, 2026 at 11:39 pm

    You can use a CASE statement and either COUNT or SUM.

    The COUNT version is below. COUNT only counts NOT NULL values so you can use any Non Null column or constant instead of 1.

    SELECT 
        COUNT(CASE WHEN Name='george' THEN 1 END) AS george_total,
        COUNT(CASE WHEN Name='michael' THEN 1 END) AS michael_total,
        COUNT(CASE WHEN Name='mike' THEN 1 END) AS mike_total /*.... rest of query*/
    

    The SUM version is

    SELECT 
        SUM(CASE WHEN Name='george' THEN 1 ELSE 0 END) AS george_total,
        SUM(CASE WHEN Name='michael' THEN 1 ELSE 0 END) AS michael_total,
        SUM(CASE WHEN Name='mike' THEN 1 ELSE 0 END) AS mike_total /*.... rest 
                                                                       of query*/
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why this query doesn’t working: SELECT name FROM ( SELECT name FROM table1 UNION
This mysql query doesn't seem to work for me: select * from myTable order
This query doesn't work SELECT * FROM Catalogue WHERE Catalogue.ID IN ( SELECT ID_catalogue
Why this query doesn't work? DELETE FROM recent_edits WHERE trackid NOT IN (SELECT DISTINCT
Is there a reason why this query doesn't work? The following query will work
This query is easy, but when the text contains some quotes it doesn't work.
This query doesn't complete in a reasonable amount of time: mysql> select * from
I'm trying to convert a PostgreSQL into SQL Server. But this query doesn't work.
INSERT INTO example_table(`id`,`name`) VALUES (MAX(id)+1,`superman`) ; The above query doesn't work, what could be
I have a query say select name from books_det ,and this query returns say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.