I have a table with the following columns
id
parent_id
title
description
weight
every row belongs to a parent. every row has a weight that determines its order on the parent page.
Every time a new row is added I want the weight of that new row to be equal to the largest weight for that parent id +1.
Is there a way to do it within the insert query?
Try this, i’m not sure it will work as i don’t have a sql server on hand. But i beleve i have done something like this before.
Replace table with your table name and the values with the ones you need, ofcourse.