[ale] Getting the next index of a table in mysql

James Sumners james.sumners at gmail.com
Thu Jun 9 08:06:19 EDT 2005


It would be better to do the INSERT first and then get the number.
That way you can be sure that it is the correct number. But, "SELECT
pri_key_num + 1 FROM table ORDER BY pri_key_num DESC LIMIT 1;"

On 6/9/05, Chris Fowler <cfowler at outpostsentinel.com> wrote:
> I have a table in MySQL that will has an integer that is the promary key
> and auto increments.  Is there a way that my software can get the next
> value that will be assigned?  I'm storing serial numbers and I have
> software that will flash a chip with that serial number.  It needs to
> flash the chip then do an insert into that table with the date and other
> information.  I need to do what value will be assigned before I do the
> insert.
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
> 


-- 
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59



More information about the Ale mailing list