Joee Joee - 3 months ago 15
MySQL Question

MYSQL: copy/clone column values to another

I can't figure it out how to clone all row values to another row
(Table 'users' with ~4k entries)

|id| login| password| email|

| 1|login1|password1|email1|

| 2|login2|password2|email2|

| 3|login3|password3|email3|


I would like to clone all 'email' row values to 'login' row for all users(id)
Values in row 'login' should be the same as in 'email'

|id| login| password| email|

| 1|email1|password1|email1|

| 2|email2|password2|email2|

| 3|email3|password3|email3|


How to figure it out?

Answer

A simple update query required:

UPDATE your_table 
SET login = email;