I’m wanting to insert a row and increment a value in all other rows after. Is there a way to do this in a single sql insert?
id | value
------------
a | 0
b | 1
c | 2
Inserting d | 2 should make the DB look like this:
id | value
------------
a | 0
b | 1
d | 2
c | 3
I agree with George Vremescu.
AFTER INSERT TRIGGERsounds like the way to go.To get the last inserted row ID you should use
last_insert_row().