Joee Joee - 1 year ago 77
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 Source

A simple update query required:

UPDATE your_table 
SET login = email;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download