I am new to MySQL. I have users table. the user has a username and nickname. The username can be null. How do I write a single MySQL query that updates the user's username by a nickname when the user has no username?
Thank you so much for your help!
UPDATE tablename SET username = nickname WHERE username IS NULL
WHERE prevents updating for a row which has username value set to something, so only rows without the value in this column are updated.
username
1.4m articles
1.4m replys
5 comments
57.0k users