Reputation: 159
I have the following query:
SET @count = 0;
UPDATE `batch_b`
SET `batch_b`.`printid` = @count:=@count+1;
ORDER BY postal_zone, country, airmail,company;
PrintID is an integer with a default value of 0. This is not the primary key. When I run the query I expect that to give one time incremental value, but it just returned NULL.
Upvotes: 0
Views: 256
Reputation: 159
It worked after wrapping the incremental value with brackets. Thank you!
Set @counter := 0;
UPDATE `batch_b`
SET `batch_b`.`printid` = (@counter:=@counter+1)
ORDER BY postal_zone, country, airmail,company;
Upvotes: 1