Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

o.k i have a problem, when i delet something from a table its idea number never comes back

o.k lets say i have a table named place1
and it have

id  -   place
1  -    idms
2  -    sds
3  -   dfdf
4 -    dffsf

and lets say i delet id number 4
and i insert onther field
dsfef
so now the table looks like that

id  -   place
1  -    idms
2  -    sds
3  -   dfdf
5 -    dsfef

so where number 4 went?

i want it
0
mgtm3
Asked:
mgtm3
2 Solutions
 
Rob SiklosCommented:
If you want it, then don't delete it!
0
 
michofreihaCommented:
In order to do that you should not make the id field autonumber...Put it as a number and the value of each new filed that you enter should be the greater value of id+1...This is the only solution
0
 
mgtm3Author Commented:
how do i do that michofreha?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
michofreihaCommented:
1-change id type from autonumber to number or int and put it unique or set it as primary key for performance
2-Select max(id) from table
3-$var=max(id)+1
4-insert into table(id,place) values($var,'dsfef')

If it you don't know how to make it work I can build the complete code for you
0
 
mgtm3Author Commented:
thank uuuuuu
0
 
michofreihaCommented:
did it work?
0
 
fiboCommented:
The point is that not reusing deleted records IDs is useful in certain circumstances: that's why, if the field is "autoincrement" previous "free" values are not reused
Autoincrement does guarantee that every new record as a unique ID, which i s also unique "over time".

In most situations you don't need to worry for holes and "missing numbers": to make it short, it does not cost a cent!

So, if these homes are really a nuisance, spend some time to turn around them: the suggested solutions will be helpful for that; if they are not a nuisance... let them happen as they will!
0
 
mgtm3Author Commented:
thankss
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now