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 7702307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:11:52+00:00 2026-05-31T23:11:52+00:00

$qb = $this->createQueryBuilder(‘t’); return $qb ->join(‘t.customers’, ‘c’) ->where($qb->expr()->eq(‘t.user’, $user->getId())) ->andWhere($qb->expr()->gt($qb->expr()->count(‘c’), 0)) ->orderBy(‘t.name’)->getQuery()->getResult(); The above

  • 0
    $qb = $this->createQueryBuilder('t');

    return $qb
        ->join('t.customers', 'c')
        ->where($qb->expr()->eq('t.user', $user->getId()))
        ->andWhere($qb->expr()->gt($qb->expr()->count('c'), 0))
        ->orderBy('t.name')->getQuery()->getResult();

The above query (Doctrine2 generated one) is giving me this error:

#1111 - Invalid use of group function

but the strange thing is i’m not using GROUP BY. Any help is much appreciated, thanks.

SELECT t0_.id AS id0,
       t0_.slug AS slug1,
       t0_.name AS name2,
       t0_.description AS description3,
       t0_.user_id AS user_id4
FROM tag t0_ 
    INNER JOIN customers_tags c2_ ON t0_.id = c2_.tag_id
        INNER JOIN customer c1_ ON c1_.id = c2_.customer_id
WHERE t0_.user_id = 1 AND COUNT(c1_.id) > 0
ORDER BY t0_.name ASC
  • 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-31T23:11:53+00:00Added an answer on May 31, 2026 at 11:11 pm

    You are using an aggregate function count() in the where clause which is not allowed.

    Conditions on aggregate functions need to go into a HAVING clause

    ....
    WHERE t0_.user_id = 1
    HAVING count(c1_.id) > 0
    

    And of course you’ll need to use a GROUP BY to get correct results (although MySQL will probably let you get away with not using a GROUP BY – but then the results are unpredictable)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to use this: $query = $this->_doctrine->createQueryBuilder() ->select('u') ->from('\Entities\Users', 'l') ->leftJoin('l.userentities', 'u') ->getQuery();
this is my query: public function getDetails($userid, $orderby, $sort){ $query = $this->_em->createQueryBuilder() ->select('u') ->from('\Entities\Users',
I try to execute this query $qb = $this->_em->createQueryBuilder(); $qb->select(array('c', 'ld')) ->from('Model\Entity\Company', 'c') ->leftJoin('c.legaldetails',
I try to execute this query in my CompanyRepository $qb = $this->_em->createQueryBuilder(); $qb->select(array('c', 'ld'))
$repository = $this->getDoctrine()->getRepository('ParabolaEntityBundle:ProjectAllocation'); $query = $repository->createQueryBuilder('p') ->where('p.startDate < :sdate and p.employee = :emp and
I have find more answer about this, but return error The option prova does
This is a bit of a long shot, but if anyone can figure it
This is starting to vex me. I recently decided to clear out my FTP,
This is kinda oddball, but I was poking around with the GNU assembler today
This might seem like a stupid question I admit. But I'm in a small

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.