Hi i want to know that how the auto increment id can be get from the mysql db for two fields in a table
+4
A:
In MySQL you're only allowed 1 auto_increment column per table.
If you try and create two you'll get:
Incorrect table definition; there can be only one auto column and it must be defined as a key
Greg
2009-11-11 14:47:00
+1
A:
Well, there are two options, but I am not sure how useful it would be (I would just use the primary key auto-increment to achieve my needs).
Using the Database: Use a trigger on the insert to increment a field value.
Using PHP: Two ways, both not so pretty:
a. grab the previous row before the insert, and increment the field in the insert.
b. If you are basing it off of the created auto-increment, you can do the insert, get the insert_id, and then update the second field.
Once again, still not sure why you would need it, but those are the options.
Cryophallion
2009-11-11 15:43:29