[MySql - Help] How can I stop the A_I from missing numbers?
#1

Hello,

Basicly, this is more of a Database question rather than Pawn itself...But its related, so i put it in this forum, designed for "Related for creating scripts for Pawn"...

---

So, I have got a table for Organisation Vehicles and the Primary key (ID) is auto incremented..

this gives me a problem because if i delete record, then the AI number just keeps going... so, at the moment my table looks like:

Код:
ID 
3
5
9
See what i mean? So, ID 1,2,4,6,7,8 are all missing because i deleted them, but when i insert the next record, it inserts it into id 10..

--

this creates a MASSIVE problem, becuase at the moment i have a loop like this:

pawn Код:
for(new i = 0; i < orgVehs; i++){
Basicly, orgvehs is the amount of vehicles i have currently got in the server and i run throught the amount of vehicles and check the database for the ID ( if i=2, i will look for the vehicle with ID 2 in the database)..

But because ID 1,2,4 etc are being skipped, then that means i am runing 6 loops that query the database which do nothing... so i have to run 9 loops, and i am only using 3 of them..

so when it gets to a larger scale...this will be VERY bad..

-----

So, anyone know how i can make it so it automaticly insert the smallest ID possible?

-thanks
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)