Skip to content
Advertisement

Whats wrong with my query, should i use WHERE?

So, what am i doing wrong?

This query:

Will give me this error:

Failed to run query: SQLSTATE[HY000]: General error: 1111 Invalid use of group function

This query:

Will give me this error:

Failed to run query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘WHERE art_nr = ‘S2Bygel’; UPDATE purchase_orderlist SET list’ at line 2

UPDATE

This was my first query. With Params:

The problem with this query is that im running two querys at the same time. and then i will get this error:

SUCCESS

I had to use prepared statements and separate my two querys:

Advertisement

Answer

You just want to add the value of $quantity_ordered to balance for the row? Then you don’t need the sum() aggregation function. Just the + operator is enough.

But it seems like you’re doing this in a host language like PHP. You should urgently learn to use parameterized queries! Do not use string concatenation (or interpolation) to get values in a query. That’s error prone and may allow SQL injection attacks against your application.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement