MySQL基于另一列数据操作更新列 [英] MySQL update column based on another column data manipulation
本文介绍了MySQL基于另一列数据操作更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一张如下所示的表格:
I have a table looks like below:
id name value newColumn
============================
1 Joe 22 null
2 Derk 30 null
newColumn 是新添加的列,我想用特定格式更新每一行的数据:concat value 和特定字符串 -CIF
newColumn is a newly added column and I would like to update the data for each and every rows with a specific format: concat value and a specific string -CIF
最终结果应如下所示:
id name value newColumn
============================
1 Joe 22 22-CIF
2 Derk 30 30-CIF
我可以知道如何在 mySQL 中构造这样的更新查询吗?
May I know how to construct such update query in mySQL?
推荐答案
这是一个相当基本的更新
:
update table t
set newColumn = concat(value, '-CIF');
这篇关于MySQL基于另一列数据操作更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文