[Cialug] SQL Question: Advanced INSERT INTO

Eric Junker eric at eric.nu
Fri Sep 3 14:47:26 CDT 2010


On 9/3/2010 2:34 PM, Todd Walton wrote:
> I'm wondering, if I need to do an INSERT INTO a table, and the table
> has a counter for a primary key, how do I handle setting the counter?
> I don't know beforehand what it should be, and it could change second
> by second.  Would something like this work?:

Are you using MySQL? If so, it is probably an auto_increment primary 
key. You don't need to specify it when inserting as it will 
automatically increment and set the primary key when you insert.

http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html

Eric


More information about the Cialug mailing list