Files
my-links/prisma/queries/set_default_next_id.sql
2023-12-14 01:01:22 +01:00

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;