MySQL Error 1054: Unknown column in sentence

Query:

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

Error display like:

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

What is the error in my request?

alt text

+3
source share
3 answers

Try using the where clause instead of the having clause:

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

I think you want to use a where clause that does not have.

+2
source

HAVING filters the units. You should try GROUP BY.

+2
source

Source: https://habr.com/ru/post/1772516/


All Articles