Jump to content

serial number and divide it over multiple database cols


Recommended Posts

Hi

I have a question, but no real example yet. 

I wonder if someone can tell how to create a serial number that counts from 10000 to 100000 en divide it as a unique id over several databases and table.columns?

I dont want to have an example with uniqid() , but counting up with one.

I have no clue how to do this can someone please give any suggestion?

 

Link to post
Share on other sites

I suppose you figure out the highest value, and add one.  Which part are you having problems with?  If you expect the database to do this automatically, it's not going to, it's up to you to look at all of the columns, figure out the highest value, and add one for the next one, and hope that you didn't create a race condition where someone else was using the site at the exact same time and happened to generate the same ID.

Link to post
Share on other sites

No.  But it's literally selecting the relevant values from whichever tables hold them, getting the max value, and adding one.  If the tables are in the same database you can use a single query to get the maximum value.

Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...