Monday 15 April 2013

select - how to copy an entry in a row to another row, but in the same column in mysql -


It may look like a trivial question but I have seen everywhere I have a table: There is no entry for id var1 1 2 9353

var1 where id = 1 and I want to duplicate the entry for Var1 from the other line to that place I have

  id var1 1 9 353 2 9 353   

I tried but failed from:

  Update table set var1 = (select var1 from table where id = 2) where it came Mr. = 1;   

Any advice? Thanks!

MySQL has its own ideas for multi-table updates (about syntax for A /) update ). It seems that except the following is necessary, I do not have MySQL to test.

  UPDATE t as t1, t as t2 SET t1.var1 = t2.var1 WHERE t1.id = 1 and t2.id = 2;   

Edit: I've changed the table name to t ; We do not want a reserved word there.

No comments:

Post a Comment