mysql 多行合并一列】的更多相关文章

mysql  多行合并一列 使用的函数为: GROUP_CONCAT(exp) 其中exp 的参数类似如下: (field order  by field   desc  separator ';'); 具体的例子如下: 创建表: CREATE TABLE `login` ( `Id` ) NOT NULL AUTO_INCREMENT, `name` ) DEFAULT NULL, PRIMARY KEY (`Id`) ) ENGINE DEFAULT CHARSET=gbk; 添加数据: ,…
mysql 行变列(多行变成一行/多行合并成一行/多行合并成多列/合并行),我觉得这都是一个意思 数据库结构如图: 而我想让同一个人的不同成绩变成此人在这一行不同列上显示出来,此时分为2中展现: 第一种展现如图----[多行变一列](合并后的数据在同一列上): sql如下: select name ,group_concat(sore Separator ';') as score from stu group by name 第二种展现如图----[多行变多列](合并后的数据在不同列上): s…
列合并和列宽度固定: .setWidth { table-layout: fixed; } .setWidth > thead > tr > th { width: 80px; } <table class="setWidth" id="EstateTable" data-mobile-responsive="true"> <colgroup> <col style="width:36px…
), VALUE )) INSERT INTO # VALUES (,,'), (,,'), (,,'), (,,'), (,,'), (,,'), (,,') SELECT code,MIN(name) AS name1,MIN(CAST(REPLACE(value,' ','') AS INT)) AS value1, THEN NULL ELSE MAX(name) END AS name2, THEN NULL ELSE MAX(CAST(REPLACE(value,' ','') AS…
本文出处:http://www.cnblogs.com/wy123/p/6910468.html 感觉最近sql也没少写,突然有一点生疏了,对于用的不是太频繁的一些操作,时间一久就容易生. 多行的某一个列合并成一个列 CREATE TABLE TestColumnMergeAndSplit ( Id ,), BusinessId int, BusinessValue ) ) GO INSERT INTO TestColumnMergeAndSplit ,'AAA' UNION ALL ,'BBB…
举例:有t_person表如下: 一.mysql行拼接: 拼接某一行: 无分隔符:select   CONCAT(id,idcard,`status`,content)   from  t_person 有分隔符:select   CONCAT_WS(',',id,idcard,`status`,content)   from  t_person 二.列拼接,最实用的功能是快速取一个大表的所有列名. SELECT   GROUP_CONCAT(COLUMN_NAME SEPARATOR ',')…
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私募机构九鼎控股打造,九鼎投资是在全国股份转让系统挂牌的公众公司,股票代码为430719,为“中国PE第一股”,市值超1000亿元.  -----------------------------------------------------------------------------------…
with a as( select * from( select 1 userId , '天津' province union select 1 userId , '北京' union select 1 userId , '上海' union select 2 userId , '北京' union select 2 userId , '上海' ) model ) select distinct userId, stuff( (select ','+province from a where u…
SELECT `w`.`id` AS `id`, `w`.`phone` AS `phone`, `w`.`belong_id` AS `belong_id`, `w`.`name` AS `name`, `w`.`password` AS `password`, `w`.`email` AS `email`, `w`.`qq` AS `qq`, `w`.`status_id` AS `status_id`, `w`.`level_id` AS `level_id`, `w`.`created_…
1,多行合并:把查询的一行或者多行进行合并. SELECT GROUP_CONCAT(md.data1) FROM DATA md,contacts cc WHERE md.conskey=cc.id AND md.mimetype_id= 5 AND md.user_id=17: 利用函数:group_concat(),实现一个ID对应多个名称时,原本为多行数据,把名称合并成一行,如|1 | 10,20,20| 本文通过实例介绍了MySQL中的group_concat函数的使用方法,比如sel…