samuelbrody1249
samuelbrody1249

Reputation: 4767

Add incrementing field on update

What would be the correct syntax to do the following in mysql?

SET @inc = 1;
update platform set package_id=(@inc := 1) where platform != 'hello';

Basically, I just want to create a pseudo-auto-incrementing field here, but it seems this just sets everything to 1. What would be the proper way to do this?

Upvotes: 0

Views: 31

Answers (1)

samuelbrody1249
samuelbrody1249

Reputation: 4767

Set it like this:

SET @inc = 0;
update platform set package_id=(@inc := @inc + 1) where platform != 'hello';

Upvotes: 2

Related Questions