MySQL error 1054: Unknown column in having clause

11,562

Solution 1

Try using a where clause in place of the having clause:

SELECT SUM(ProductCost) 
FROM `tblBasket` 
WHERE BasketSessionID ='3429782d79c68834ea698bb4116eef5e'
GROUP BY ProductCode

Solution 2

I think you want to use a where clause not having.

Solution 3

HAVING filters out aggregates. You should try GROUP BY.

Share:
11,562
Bharanikumar
Author by

Bharanikumar

technical link click pannu pa Try pannunga

Updated on June 08, 2022

Comments

  • Bharanikumar
    Bharanikumar almost 2 years

    Query:

      SELECT SUM(ProductCost) 
        FROM `tblBasket` 
    GROUP BY ProductCode
      HAVING BasketSessionID = '3429782d79c68834ea698bb4116eef5e'
    

    Showing Error Like:

    1054 - Unknown column 'BasketSessionID' in 'having clause'

    What is the mistake in my query?

    alt text