Jump to content

serial number and divide it over multiple database cols


BrainPill

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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...