chaitanya
chaitanya

Reputation: 352

How can i update one value with another value in mysql

How can I update the username field with the email field value for all the records on the table.

update table1 set username = (select email from table1);

I know it is wrong method. But I am not getting the correct way to do this.

Upvotes: 0

Views: 46

Answers (2)

ngrashia
ngrashia

Reputation: 9894

Sample Data:

Uname  Email
a      [email protected]
b      [email protected]
c      [email protected]

Upvotes: 2

VMai
VMai

Reputation: 10336

Simply use

UPDATE table1 SET username = email;

Upvotes: 3

Related Questions