MySQL: update one table with data from one column to another column

I have a MySQL table called Cars. The table Carshas three columns: id int auto increment, foo varchar(255), bar varchar(255).

I want to just update all the rows of the Cars table in a column barwith the same value from foo, if foonot null. Thus, both foo and bar will have the same value after the update, where foo is not null.

+5
source share
3 answers
update cars set
bar = foo
where foo is not null
+9
source
UPDATE cars SET bar = foo WHERE foo IS NOT null
0
source

Update Request:

 UPDATE Cars set bar = foo where foo is not null
0
source

All Articles