samedi 3 août 2019

Group based auto increment

In my employees table entities are employee_id, name, type

there are 3 types of employees. those are : ST, WF, WP

So when a employees info enter into the database table would be like this

employee_id  name     type
WP 1          john      WP
WP 2          doe       WP
ST 1          jhonny    ST
WF 1          tuna      WF
ST 2          tian      ST
WP 3          Rian      WP

Problem here is How to enter employee_id auto increment based on type

there is one solution could be like it will count employee type from table and add count+1 based on type. but the problem when multiple user enter employees database into table multiple user will get same count and employee_id won't be unique.

How do i get optimum solution? Thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire