There is a database where id AUTOINCREMENT. How to make a query in such a way, what would this id, which was, autoincrement pulled out and inserted into another field in the same table? The picture is more understandable. Id field and weight

UPDATE tab SET weight = id WHERE weight= 0 mysql_insert_id() returns 0 if the previous query does not generate an AUTO_INCREMENT value. If you need to save the value for the future, call mysql_insert_id () immediately after the query that generates this value.
INSERT INTO table VALUE (NULL, 0, 0); UPDATE table SET weight = LAST_INSERT_ID() WHERE id = LAST_INSERT_ID(); Do you mean that when adding a new record, immediately register the ID of this record in some field? If so, you can get this ID before requesting an INSERT.
$res_id = mysql_query("SHOW TABLE STATUS LIKE 'table_name';"); $row_id = mysql_fetch_assoc($res_id); $id = $row_id['Auto_increment']; table_name ( weight ) SELECT AUTO_INCREMENT FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'db_name' and TABLE_NAME = 'table_name' If you are a little more familiar with this than with the work of architects, then there should be no questions)) - DeonisSource: https://ru.stackoverflow.com/questions/101524/
All Articles