Jump to content

id auto_increment on multiple tables


a2bardeals

Recommended Posts

i have an online order process witch places orders into two types of orders reperesented by two different tables in a MySQL database ('transfers' & 'dupliaction'). I am trying to create a unique order number ('ID') field in both tables that auto_increments but so that there are not duplicate ids in the 2 tables.
Basically,
If someone places a transfer order it assigns the order ID: 00001 in the table 'transfers' and then another customer comes along and places a duplication order it will assign the duplication order ID: 00002 [b]rather than[/b] 00001 becuase its the first in the table 'duplication'. This is for order processing and shipping sanity.
Link to comment
Share on other sites

You would have to have a go-between table, that records what id's have been used, and what has not, so you can assign id's according to that.  Rather complicated process.  I don't see the point, there probably are other solutions, other than the way you are trying to do it, what are you trying to do exactly overall.
Link to comment
Share on other sites

well the orders for transfers have totally different options (fields) than the duplication orders so its hard to have them in the same table. For web sanity i need to keep them seperate and for accounting and customer service sanity i need to have a unique id for each different project. I will try the go between table and let you know how it works.

p.s. it would be nice if somehow i could add an identifier in the Order Number like WT0003 for a "Web: Transfer" or WD0004 for "Web: Duplication".

Can i generate the number from MySQL auto_increment or would i have to write a script that checks the last four digits of the last order in the orders table and adds one?
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.