mysql - how to put value of the upper row in the bottom rows -
i have table this:
+-----+------------+ | id | name | |-----|------------| | 1 | ali | |-----|------------| | 2 | | |-----|------------| | 3 | | |-----|------------| | 4 | peter | |-----|------------| | 5 | | +-----+------------+
i want put value of upper row bottom rows. (if bottom row empty). thing this:
+-----+------------+ | id | name | |-----|------------| | 1 | ali | |-----|------------| | 2 | ali | |-----|------------| | 3 | ali | |-----|------------| | 4 | peter | |-----|------------| | 5 | peter | +-----+------------+
is possible ?
how this?
update t set name = (case when name not null @name := name else @name end) order id;
it seems easiest method using mysql.
Comments
Post a Comment