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

  • Home
  • SEARCH
  • 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 8773485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:18:24+00:00 2026-06-13T18:18:24+00:00

does someone knows why this first query works and this second not? first query

  • 0

does someone knows why this first query works and this second not?

first query (works):

SELECT *, 
       MATCH(username) AGAINST ('ergergergergergerg' IN BOOLEAN MODE) AS _score
FROM (ci_users) HAVING _score > '0';

second query (not working):

SELECT COUNT(id), 
       MATCH(username) AGAINST ('ergergergergergerg' IN BOOLEAN MODE) AS _score 
FROM (ci_users) HAVING _score > '0';

the first query returns exactly 24 rows, the second query returns 0 rows, while i just changed * to COUNT(id)

  • 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-06-13T18:18:25+00:00Added an answer on June 13, 2026 at 6:18 pm

    The first one return every row that matches.

    The second one contains an aggregation on id.

    When aggregating, MySQL is smart enough (or should I say, stupid enough) to implicitly pick a any value from all fields that are queried, but not aggregated. So since you don’t group by score and you don’t aggregate score, MySQL will just return any of the scores of all records, of the intermediate result (before applying the having clause) including those that have a value of 0. So, this intermediate result may very well contain just a count of, say, 900 and a _score of 0. After filtering using having, no records remain.

    Now, I would be happy to do a suggestion, but I cannot tell what you would actually want to be returned from that query.

    SELECT COUNT(id)
    FROM
      (SELECT 
        id,
        MATCH(username) AGAINST ('ergergergergergerg' IN BOOLEAN MODE) AS _score 
      FROM (ci_users) HAVING _score > '0') x;
    

    Or even better:

    SELECT COUNT(id)
    FROM (ci_users) 
    WHERE MATCH(username) AGAINST ('ergergergergergerg' IN BOOLEAN MODE) > '0'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does someone know why this is not a strict quine ? _0='_0=%r;print _0%%_0';print _0%_0
Does someone knows the image-crop which correctly works with the 'dynamically changed in the
i am getting this error does some one knows about it??? 2009-07-08 18:42:36.778 FlashCards[1297:20b]
This StackOverflow answer has an image of KDiff3 highlighting intra-line differences. Does someone know
Does someone knows why the mysql_real_escape_string() function adds three backslashes before quotes, or double
Does someone knows how can I capture my computer screen to a video file?
Does someone knows how to calculate the total hours between 2 times? For example
Does someone know why i never get the first value of my array? it
First off, here's my SQL query: SELECT research_cost, tech_name, (SELECT research_cost FROM technologies WHERE
I have a query that, basically, says this: SELECT DISTINCT [DB_ID] FROM [TableX] WHERE

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.