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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -