(MYSQL学习笔记3)mysql两行数据合并成一行
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了(MYSQL学习笔记3)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;
本文出自 “w1sw” 博客,请务必保留此出处http://cfdeng.blog.51cto.com/9873532/1944324
以上是关于(MYSQL学习笔记3)mysql两行数据合并成一行的主要内容,如果未能解决你的问题,请参考以下文章