MySQL中字符串和数字拼接

select * from qa_employ where EMPLOY_GROUP =2

原先雇佣表中所有雇佣姓名全部是"张三",

希望将雇用姓名变得不一样,比如张三+id

SQLserver中直接用

 

update   qa_employ
set EMPLOY_NAME = EMPLOY_NAME+EMPLOY_id
where EMPLOY_ID > 10

即使发现EMPLOY_id是int类型,最多用cast转一下

 

update   qa_employ
set EMPLOY_NAME = EMPLOY_NAME+cast (EMPLOY_id as char)
where EMPLOY_ID > 10

但在mySQL报错

 1292 - Truncated incorrect DOUBLE value

 

update qa_employ
set EMPLOY_NAME = concat("开发人员",EMPLOY_id)
where EMPLOY_ID > 10

 

update qa_employ
set EMPLOY_NAME = concat("开发人员",EMPLOY_id)
where EMPLOY_ID > 10

  

猜你喜欢

转载自www.cnblogs.com/qianjinyan/p/10373032.html
0条评论
添加一条新回复