I've just got a situation where i need to duplicate the unique (auto-incremented) id of each new row in another column. So I was wondering, instead of doing it the old fashioned way:
- Insert row
- Get insert_id
- Update row with the insert_id
Can I tell MySQL to use the same value to which the new id is going to be set, as a value for another column?
Something along the line of this:
INSERT INTO my_table(unique_column, id_duplicate)
VALUES('value', GET_UNIQUE_ID_OF_THIS() )