At localhost I want to replace all of emails with their usernames. This is not works:
UPDATE `users` SET 'email'='username'
What is the working code?
At localhost I want to replace all of emails with their usernames. This is not works:
UPDATE `users` SET 'email'='username'
What is the working code?
Assuming you have a field called username
in the data:
update users set email = username;
Your code is confusing back quotes with regular quotes (which are used only to delimit strings). You could also write:
update `users` set `email` = `username`;
Back quotes are used to enclose column and table names, particularly when they have unusual characters (like spaces) or conflict with reserved names.
because you have wrap the column name with single quotes. Remove it and it will work.
UPDATE users SET email = 'username'
backticks are only used to escape reserved keywords or column names and tables names that have special characters on it. More explanation on the link below.
but if you mean to copy the values of column username
into email
, you need to remove the quotes on both column,
UPDATE users SET email = username