i have the db with serial no and reference no. serial no is auto_increment value. it is worked perfectly. but i want ref no column also as auto_increment value start with 0000001,0000002,0000003...., how to do that? i cannot able to add two auto_increment values in mysql.

Recommended Answers

All 2 Replies

Member Avatar for diafol

If both are in sync, you can calculate one from the other, e.g.

Serial No | Ref No
3 | 10
4 | 11
5 | 12

So effectively, you don't need a Ref No. It's just the serial no. + 7 (in this case).

I would increment 1,2,3 and preprend 000000.
If your two columns are numerically in sync, as auto-increment would suggest, then you could use a formula and not have a ref column.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.