Tristan,

It is a simple question and the answer be found very easily in the MySQL
manual. All you need to do is to create a column in your table of type
AUTO_INCREMENT. Then, when you insert a row into the table, you simply
insert NULL as the value for the auto-incremented column and it will be
automatically incremented to the next value.

Other questions normally related to this topic:
1. Don't worry about "gaps" in the values in this field when you delete
information from the table. These auto-incremented values are only meant to
be identifiers, not necessarily ordinal values, for your table.

2. To find out the value of the ID of the last row inserted into a table
with an AUTO_INCREMENT column, use PHP's mysql_insert_id() function.

Hope this helps.
Rich


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 8:45 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Auto inc in MySQL


I know I'll get flamed for askign such a simple question, but here goes...

I have a MySQL DB and wanna increment a field 'id_number' by one each
time, to avoid creating duplicates...
I've done it before, but can't remember how...
Any ideas?

Tris...

*********************************************************************
The information contained in this e-mail message is intended only for
the personal and confidential use of the recipient(s) named above.
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is
strictly prohibited. If you have received this communication in error,
please notify us immediately by e-mail, and delete the original message.
***********************************************************************



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to