MySQL help
#6

Quote:
Originally Posted by JamesC
Посмотреть сообщение
Why exactly do you want to do this?
Let's say a house system in which the IDs are IMPORTANTLY stored by sequence. And let's say that any missing ID would screw the whole system up. So when we create a new house, it finds that "Missing" # and inserts it there. ( This is not my system, just an example )

Quote:
Originally Posted by MP2
Посмотреть сообщение
But he doesn't know which one - read his post.

Can't the INSERT ID thing be used? Not sure.
Nope.

Quote:
Originally Posted by [HiC]TheKiller
Посмотреть сообщение
pawn Код:
new id, xid[10];
mysql_query("SELECT id FROM table");
mysql_store_result();
while(mysql_retrieve_row())
{
    id++;
    mysql_fetch_field_row(xid, "id"); //Not sure about mysql_fetch_int (May be able to use it in this case)
    if(strval(xid) != id) return id;
}
mysql_free_result();
/*
The code above will return the ID that
is missing from the sequence. This is
not really a good idea though, and
there is not many reasons for
doing something like this.
Edit: This worked perfectly. Thanks so much!!
Reply


Messages In This Thread
MySQL help - by -Prodigy- - 21.02.2012, 00:06
Re: MySQL help - by JamesC - 21.02.2012, 01:05
Re: MySQL help - by s0cket - 21.02.2012, 01:19
Re: MySQL help - by MP2 - 21.02.2012, 03:10
Re: MySQL help - by [HiC]TheKiller - 21.02.2012, 04:32
Re: MySQL help - by -Prodigy- - 21.02.2012, 16:36

Forum Jump:


Users browsing this thread: 1 Guest(s)