Update Mysql records using Same table but Based on same table record I have table in which i want to update records based on it's 'wishlist_id' value.
Sample format of table records.


Expected table record after update.



So can you help to update this record using mysql query?
Assuming that all records with wishlist IS NULL must be updated with the value taken from the closest previous (while sorting by id ASC) record with non-NULL wishlist value:

UPDATE test
SET wishlist = (@tmp := COALESCE(wishlist, @tmp))
WHERE (@tmp := -1)
ORDER BY id ASC


fiddle