How to increment the code field of type varchar () automatically in MySQL?

0

I need to do a stock control, where the product code should be varchar , because the code will be formed by the short name of the product category followed by a sequential number, so I will not use the product_ID column that is int , but I'm going to use product_codev , which is varchar , and needs to be auto incremental. How do I do it with triggers ?

    
asked by anonymous 13.04.2016 / 02:11

1 answer

0

Leave product_ID as auto_increment and trigger after insert . So you can mount product_codev as you see fit.

Now if I can give you a suggestion, I think this product_codev could be mounted in the application, since it is apparently something to present to the user and not to ensure the consistency of the data.

    
13.04.2016 / 02:22