View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 09:07 AM
eholz1
 
Posts: n/a
Default Can I determine the index (value) of an auto-increment field

Hello MYSql Lovers,

Is there a handy way (using PHP) to determine the value of an auto-
increment field when I am going to
insert a record into a table?

by this I mean, without counting the records in the table already and
adding 1? or using MAX(id) + 1 ,etc?

A more challenging question (for me at least), suppose I have an empty
table with an auto-increment field (id),
and I am going to insert all the files in a given directory in the the
database table, at insert time, is there a way I can predict (or know)
the value of "id"??

I would like to create a value in another field based on the value (a
number) of the id field.
Like col1 value = id + (MOD %30 of id).

I know that i can load the table first, then do an update on col1
using the formula based on the value of "id".

I was wondering if there was a better way, etc.

thanks
eholz1

Reply With Quote