sql - MySQL - Update siblings with same key -
couldn't find solution yet... although newbie question, haven't been able overcome... hope can give hand.
i have mysql table has:
blockquote
col1 col2 row1 null row2 a1 row3 null row4 b null row5 b b1 etc > blockquote
how construct sql update update col2, values on col2 replace null, ie, c2r1 , c2r3 gets a1, , c2r4 gets b1 ?
you can calculate required values follows:
create temporary table yourtemptable select yourtable.col1, t1.col2 yourtable join ( select col1, max(col2) col2 yourtable group col1 ) t1 on yourtable.col1 = t1.col1
you can either drop/truncate original table , recreate using these values, or if can't drop table can instead perform multi-table update.
Comments
Post a Comment