The first column in my MySQL table contains an auto increment ID. I would like to enter this value into another column when inserting a new row into the table, i.e. I need to read the value in the ID column and insert it into the next column.
Is it possible to do this, and if so, how?
I’m sure some of the above answers work, but I wasn’t able to work out how to implement them. I did however successfully implement a solution using
$pdo->lastInsertId(), i.e. after executing my INSERT query I added:And this sets the fav_id column of the last inserted row to the same value as the id column for this row, if fav_id has not already been set.