如何合并mysql两行数据成一行

作者: xiaozhu 发布时间: 2023-01-04 浏览: 1495 次 编辑
下面讲讲关于如何合并Mysql两行数据成一行,文字的奥妙在于贴近主题相关。所以,闲话就不谈了,我们直接看下文吧,相信看完如何合并mysql两行数据成一行这篇文章你一定会有所受益。

使用SUM函数,加上GROUP BY人员ID就可以实现了:

SELECT SUM(PZ+CPjs+BZ+GC+SB+TG+MJ+CL+CCLW+GJ+ZL+CBZZ) as count,
SUM(PZ) as PZ,SUM(CPJS) as CPJS,SUM(BZ) as BZ,SUM(GC) as GC,SUM(SB) as SB,SUM(TG) as TG,
SUM(MJ) as MJ,SUM(CL) as CL,SUM(CCLW) as CCLW,SUM(GJ) as GJ,SUM(ZL) as ZL,SUM(CBZZ) as CBZZ,SUM(YHID) as YHID,
SUM(DJRMC) as DJRMC FROM tableName WHERE YHID='$ID' AND NF='$NF' GROUP BY YHID;

对于以上如何合并mysql两行数据成一行相关内容,大家还有什么不明白的地方吗?或者想要了解更多相关,可以继续关注我们的数据库板块。