mysql表中类似excel的计算

mysql表中类似excel的计算,mysql,Mysql,如果有两列id1和id2显示了值,mysql是否可以将这两列(添加两个字段)合并到第三个id中 (在excel中很容易做到这一点-使用公式从excel表格的两列中获取值,并在第三列中执行计算)。谢谢您可以这样做: 如果要压缩字符串,可以执行以下操作: update table set id = concat(id1,id2); 如果要添加: update table set id = (id1+id2); 您可以这样做: 如果要压缩字符串,可以执行以下操作: update table set

如果有两列id1和id2显示了值,mysql是否可以将这两列(添加两个字段)合并到第三个id中

(在excel中很容易做到这一点-使用公式从excel表格的两列中获取值,并在第三列中执行计算)。谢谢

您可以这样做: 如果要压缩字符串,可以执行以下操作:

update table set id = concat(id1,id2);
如果要添加:

update table set id = (id1+id2);
您可以这样做: 如果要压缩字符串,可以执行以下操作:

update table set id = concat(id1,id2);
如果要添加:

update table set id = (id1+id2);
是的,你能行

select firstCol, secondCol, concat(firstCol, secondCol) as thirdCol
from table name
是的,你能行

select firstCol, secondCol, concat(firstCol, secondCol) as thirdCol
from table name

您可以使用MySQL提供的concat()函数您可以使用MySQL提供的concat()函数可以在插入数据时执行吗?i、 e.使用INSERT命令?那么,在那个时候,您可以很容易地像INSERT一样插入到tablename(firstCol,secondCol,thirdCol)值($firstCol,$secondCol,$thirdCol);而您需要定义#thirdCol=$firstCol.''.$secondCol;定义$thirdCol=$firstCol.''.$secondCol在php或您所指的服务器语言中是。您想使用哪种语言?可以在插入数据时使用吗?i、 e.使用INSERT命令?那么,在那个时候,您可以很容易地像INSERT一样插入到tablename(firstCol,secondCol,thirdCol)值($firstCol,$secondCol,$thirdCol);而您需要定义#thirdCol=$firstCol.''.$secondCol;定义$thirdCol=$firstCol.''.$secondCol在php或您所指的服务器语言中是。您想使用哪种语言?谢谢您提供的附加信息。谢谢您提供的附加信息。