this is an example:
table mysql schema :
id name salary 1 david 20 2 jack 30 3 david 10
Query:
$sql = "UPDATE table SET salary = salary + 5 WHERE name = 'david' ";
I want to added Group By name to avoid duplicate update for david
How Could I do that?
Try using LIMIT, which is an extension to SQL used by MySQL:
It makes no sense to use GROUP BY, because it would be ambiguous whether to update the first row in the group, or the last row, or all of the rows. MySQL does not support a GROUP BY clause in the UPDATE statement.