doc_id (1) staff_id(170) 2 均为int
如果要将这三个值相加,得到11702,就必须相将三个字段转化成整形
如下:
select staff_id,str(doc_id)+str(staff_id)+str(2) as 'id' from flow_status where doc_id ='1'
得到的 结果如下:
这明显不符合我们的要求,
可以改成如下方法:
select staff_id, (cast(doc_id as VARCHAR(10)) + cast(staff_id as VARCHAR(10)) + cast(2 as VARCHAR(10))) as 'id' from flow_status where doc_id ='1'