zoukankan      html  css  js  c++  java
  • mysql指定字符位置截取字符串(多行重复信息进行合并)

    select number ,SUBSTRING_INDEX(GROUP_CONCAT(name ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(idcard ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(branch ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(department ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(direct_superior ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(position ORDER BY name desc ),',',1),
    SUBSTRING_INDEX(GROUP_CONCAT(location ORDER BY name desc ),',',1),
    GROUP_CONCAT(datasources ORDER BY name desc )
    from employee_information GROUP BY number

    使用SUBSTRING_INDEX()函数
    substring_index(str,delim,count)

    str:要处理的字符串

    delim:分隔符

    count:分隔符计数 

    例子
    取出上述表中数组的第一个元素

    -- SUBSTRING_INDEX(str,'"',2)取出从左往右第二个引号左边的字符串str
    -- SUBSTRING_INDEX(str1,'"',-1)取出从右往左数第一个引号右边的字符串str_1

  • 相关阅读:
    理解java的三大特性之封装
    特征学习
    Java类编译、加载、和执行
    榜样
    组合学习模型
    python的re模块详解
    python的argpare和click模块详解
    vue的组件
    vue的表单输入绑定
    vue的事件处理梳理
  • 原文地址:https://www.cnblogs.com/qinyios/p/12166164.html
Copyright © 2011-2022 走看看