Copy data from one cell to another - MySQL

Viewed 745

So, I've been googling for a while now and can't seem to find the answer:

What I want is a query for copying data from one cell to another of the same table, something like:

COPY column1 FROM mytable WHERE id=1 TO WHERE id=5

So now I would have the same data in column1 on id 1 and id 5

PS: If there is a solution on phpmyadmin that'd be amazing too, I can work with anything

Thanks in advance for the help!

2 Answers

You need something like this

update mytable set column1 = (select column1 from (select column1 from mytable where id = 2) as alias) where id = 5;
SELECT column1 INTO @column1_Value FROM mytable where id = 2;

update mytable set column1= @column1_Value where id = 5;
Related