Hi,
I have several tables - e.g. Products, Manufacturers, that has a unique ID associated with each row - e.g. ProductID, ManufacturerID.
When I delete rows in the middle of the table, I want to reassign the IDs into numerical order.
Also, when I insert a row at the end, I want to know the last ID in the table without having to read the whole table.
How do I carry out both operations, and should this be carried out via a MySQL query, or via PHP?
Many thanks
Unqiue ID columns - PHP or MySQL query?
Moderator: General Moderators
dont reassign the IDs, if you have used them as foreign keys then you would need to update all those records also. Dont do it.
To get the last generate ID use
mysql_insert_id() funtion
http://www.php.net/manual/en/function.m ... ert-id.php
To get the last generate ID use
mysql_insert_id() funtion
http://www.php.net/manual/en/function.m ... ert-id.php