I'm new at creating database and currently trying to accomplish something that is really necessary for me.
Lets say I have a Database "Customer" with 300 rows all with a unique identifier called Id_
.
Id_ | Customer | Postal | Country |
200 | Mica Sa. | 99582 | USA
201 | Shum Jr. | 10258 | USA
202 | Carl Ro. | 45697 | USA
203 | Brad Mi. | 24761 | USA
If i delete a row number 202 using:
DELETE FROM Customer
WHERE Id_ = 202;
I Get:
Id_ | Customer | Postal | Country |
200 | Mica Sa. | 99582 | USA
201 | Shum Jr. | 10258 | USA
203 | Brad Mi. | 24761 | USA
But when I try to insert a row using:
INSERT INTO Customer (Id_, Customer, Postal, Country)
VALUES (202, 'Peter R.', 08574, 'USA');
I get the row randomly inserted in the database, so my question is how do I insert this row exactly after 201(Id_)
and before 203(Id_)
?
To help you clear some things up:
If ID are actually of type int I recon you make them auto incremental
Select * from Customer Order by Id_ Desc