mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
11 lines
275 B
SQL
11 lines
275 B
SQL
-- set default next id for each category based on LEAD(id) (LEAD -> Next)
|
|
|
|
UPDATE category AS c
|
|
JOIN (
|
|
SELECT
|
|
id,
|
|
LEAD(id) OVER (PARTITION BY authorId ORDER BY id) AS nextCategoryId
|
|
FROM category
|
|
) AS n ON c.id = n.id
|
|
SET c.nextId = n.nextCategoryId;
|