BrainPill Posted March 8, 2018 Share Posted March 8, 2018 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 More sharing options...
justsomeguy Posted March 8, 2018 Share Posted March 8, 2018 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 More sharing options...
BrainPill Posted March 8, 2018 Author Share Posted March 8, 2018 Do you know and example online about how to do this? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 8, 2018 Share Posted March 8, 2018 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now