0

I was thinking of formatting it like this

TYYYYMMDDNNNN (2 character + 12 digits)

Where

T is character (TR or SL) YYYY is year (2018) MM is month (03) DD is day (30) N is sequential number (0001, 0002, 0003 etc.)

I need auto increment N after getting last data from mysql database.

Such as

20180330-0001, 20180330-0002, 20180330-0003.

20180331-0001, 20180331-0002.

20180401-0001, 20180401-0002, 20180401-0003 etc.

  • You want to build a composite primary key? What is your db engine? https://stackoverflow.com/questions/18120088/defining-composite-key-with-auto-increment-in-mysql – mickmackusa Mar 30 '18 at 00:29
  • Twitter snowflakes would be an option too, as unique ID. – Charlotte Dunois Mar 30 '18 at 00:37
  • It is almost never a good idea to combine two pieces of information into a single column. In this case, use a column with the date, and another that increments with each access. You can create an index on the two columns and you're good to go. – Jerry Mar 30 '18 at 02:35

0 Answers0