bswinnerton
bswinnerton

Reputation: 4721

How to increment text value in SQL

I have a table in MySQL that is titled accounts, inside of accounts I have: email, first_name, last_name, etc. What I'd like to do is replace all of the email accounts to a generic value, but have each one contain an incremented value at the end. How can I do this in sql?

So for example, [email protected] would turn into [email protected] and the next would go from [email protected] to [email protected], and so on.

Upvotes: 0

Views: 577

Answers (1)

vearutop
vearutop

Reputation: 4062

SET @seq = 0;
UPDATE users SET email = CONCAT('replacedemail', @seq := @seq + 1, '@gmail.com')

Upvotes: 1

Related Questions