When the data in column 1 is equal to the data in column 2, what is the harm in updating the row anyways?
UPDATE table SET column2 = column1
The data is always set in column 2 but when it was already the same data then column 1 nothing has changed
After reading your comment, I suggest the following:
Remove column 2 and create a new table called previous_usernames
Add 3 columns to that table
id
, user_id
and username
Update this table when the username is changed, not afterwards with a cron. That is unneccesary complicated.
first run this query INSERT INTO previous_usernames (user_id, username) (SELECT id, username FROM users WHERE id = ?)
Then run this query UPDATE users SET username = ? WHERE id = ?
When you want to make sure that the old username is stored correctly you can use transactions
After reading your new comments I suggest the following
You could create a UNIQUE index on the username and GUID column and try to insert every row. When the username and GUID combination exists, the query will fail and the record not be inserted.
How do I specify unique constraint for multiple columns in MySQL?