Reputation: 4416
I'm using Netbeans as my IDE and MySQL as my database, I want to create auto increment id coming up with Strings Like USER101, USER102,... How can I create this auto-increment id? I tried this method do generate auto-increment id in integer
Upvotes: 1
Views: 952
Reputation: 49385
If id is your auto increment column, make a second generated column with
CONCAT(''USER'',id);
As generating formula.
The next code would change a column to generate automatocally the USER101 depending on the id from the autoincrement.
ALTER TABLE `testdb`.`testtable`
CHANGE COLUMN `columname` CHAR(50) NULL GENERATED ALWAYS AS (CONCAT('USER',id));
But i don't know how you make this in NEtbeans and google also didn't help.
Upvotes: 1