I have a PHP page which interacts with this small MySQL database table with a simple structure. ID
, Name
, Address
are the fields. ID
is the primary key.
+------+------------+-------------+
| ID | Name | Country |
|______|____________|_____________|
| E001 | Stephen | America |
| E002 | John | Britain |
| E003 | Kate | Canada |
| E004 | Carlos | Spain |
| E005 | James | Australia |
|______|____________|_____________|
If I remove the record at E003, it looks like this.
+------+------------+-------------+
| ID | Name | Country |
|______|____________|_____________|
| E001 | Stephen | America |
| E002 | John | Britain |
| E004 | Carlos | Spain |
| E005 | James | Australia |
|______|____________|_____________|
A gap appears between E002 and E004.
Is there a way to fill in that gap? Like this
+------+------------+-------------+
| ID | Name | Country |
|______|____________|_____________|
| E001 | Stephen | America |
| E002 | John | Britain |
| E003 | Carlos | Spain |
| E004 | James | Australia |
|______|____________|_____________|
Earlier record which had E004, fall into the place of E003. Former E005 gets the number E004 and so on. Like the records take a step back.
Is there a way to do this programmatically?