zoukankan      html  css  js  c++  java
  • 6.10 根据表中的行创建一个分隔列表

    要将如下的数据:

    +--------+--------+
    | deptno | ename  |
    +--------+--------+
    |     30 | ALLEN  |
    |     30 | WARD   |
    |     30 | MARTIN |
    |     30 | BLAKE  |
    |     10 | CLARK  |
    |     10 | KING   |
    |     30 | TURNER |
    |     30 | JAMES  |
    |     10 | MILLER |
    +--------+--------+

    转换为下列内容:
     deptno   emps                                 
    --------  --------------------------------
         10   CLARK,KING,MILLER                     
         30   ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES  

    解决方案:

    select deptno,
    group_concat(ename order by empno separator ',') 
    from emp
    group by deptno;
    +--------+--------------------------------------+
    | deptno | emps                                 |
    +--------+--------------------------------------+
    |     10 | CLARK,KING,MILLER                    |
    |     30 | ALLEN,WARD,MARTIN,BLAKE,TURNER,JAMES |
    +--------+--------------------------------------+

  • 相关阅读:
    Java中Bitmap的实现
    链接备用
    91家纺网,利用cookies登录
    selenium验证码pic处理代码,以91家纺网为例
    91家纺网,登录代码
    91家纺网,模拟浏览器登录
    91家纺网,models
    91家纺网,setting文件
    91家纺网,更新
    91家纺网,更新
  • 原文地址:https://www.cnblogs.com/liang545621/p/7523166.html
Copyright © 2011-2022 走看看