@oranoos3000
I'm not sure this is the best way but this just came to mind.
You can have an inline query that adds one to the previous record's second counter field.
-
-
INSERT INTO yourTable SET secondAutoInc = ((SELECT secondAutoInc FROM yourTable ORDER BY 1 DESC LIMIT 1) + 1);
-
-
This is not a solution. There's a reason MySQL allows you to set only one auto-increment field: If you have a need for two, your application logic is screwed up.
We might help you save time (and possibly money) if you explain your intentions and why you're trying to have two fields increment?
*Boring to read, continue at own risk*:
If you want to know why a record does not need to auto-increment consider this: When you ID (tag,lablel) something, anything can refer to it by this ID or tag. For example, we all need only ONE driver license number. The police and government can uniquley identify each person by their number so why have two numbers to be identified by. It will only make things more confusing.
If your second field is not a key value (not used for identification but more of a display number (that is also unique)), then what you could do is just multiply (or add, subtract, divide) that field by a constant number to generate another unique ID. If you created a row with ID 5, your second field could be 5500 (5*1100). Here you just multiplied by 1100 to get another number that is better looking for an invoice or order number.
************ END OF BORING ******************
Let me know if you have any questions,
Dan