Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL error 1054: Unknown column in having clause

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

like image 903
Bharanikumar Avatar asked Dec 05 '22 01:12

Bharanikumar


2 Answers

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

SELECT SUM(ProductCost) 
FROM `tblBasket` 
WHERE BasketSessionID ='3429782d79c68834ea698bb4116eef5e'
GROUP BY ProductCode
like image 68
codaddict Avatar answered Dec 08 '22 05:12

codaddict


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

like image 35
Jon Snyder Avatar answered Dec 08 '22 04:12

Jon Snyder