MYSQL Table creation with default value(expression) to a column

前端 未结 2 1471
忘掉有多难
忘掉有多难 2021-01-03 08:13

I have a Table Employee(id,name,dept_name).I want the id will alphanumeric [ffffdddaaaaa] with first 5 digit will be auto increment id and rest 4 cha

2条回答
  •  梦谈多话
    2021-01-03 09:14

    You could try concatenating it in your select statement instead of storing an auto increment column and an id column,

    SELECT CONCAT(id, substring(name,4) FROM tbl_employee
    

    That way you wouldn't need triggers

提交回复
热议问题