Back (Current repo: scraps)

random scraps and notes that are useful to me
To clone this repository:
git clone https://git.viktor1993.net/scraps.git
Log | Download | Files | Refs

update_ranks.sql (280B)


SET @ROW := 1;

UPDATE some_table t
JOIN (
    SELECT id
    FROM some_other_table
    WHERE some_value IN (111,123)  -- Optional filtering
    ORDER BY id              -- Important: define row order
    LIMIT 10000
) ordered ON t.id = ordered.id
SET t.rank = (@ROW := @ROW + 1);