Mysql截取字段中 用逗号分割 省市县镇街道社区小区

Mysql截取字段中 用逗号分割  省市县镇街道社区小区


select id , name, 
substring_index(name,',',0) as province0,
substring_index(name,',',1) as province1,
substring_index(name,',',2) as province2,
substring_index(name,',',3) as province3,
substring_index(name,',',4) as province4,
substring_index(name,',',5) as province5,
substring_index(name,',',6) as province6,substring_index(name,',',1) as a1,
SUBSTRING_INDEX(substring_index(name,',',1) ,  CONCAT(substring_index(name,',',0),',') ,-1)  a11,
SUBSTRING_INDEX(substring_index(name,',',2) ,  CONCAT(substring_index(name,',',1),',') ,-1)  a2,
SUBSTRING_INDEX(substring_index(name,',',3) ,  CONCAT(substring_index(name,',',2),',') ,-1)  a3,
SUBSTRING_INDEX(substring_index(name,',',4) ,  CONCAT(substring_index(name,',',3),',') ,-1)  a4,
SUBSTRING_INDEX(substring_index(name,',',5) ,  CONCAT(substring_index(name,',',4),',') ,-1)  a5,
SUBSTRING_INDEX(substring_index(name,',',6) ,  CONCAT(substring_index(name,',',5),',') ,-1)  a6 from testwhere SUBSTRING_INDEX(substring_index(name,',',5) ,  CONCAT(substring_index(name,',',4),',') ,-1)   = '社区'

 

 

select id , name, 
substring_index(name,',',1) as province1,
substring_index(name,',',2) as province2,
substring_index(name,',',3) as province3,
substring_index(name,',',4) as province4,
substring_index(name,',',5) as province5,
substring_index(name,',',6) as province6,substring_index(name,',',1) as a1,
SUBSTRING_INDEX(substring_index(name,',',2) ,  CONCAT(substring_index(name,',',1),',') ,-1)  a2,
SUBSTRING_INDEX(substring_index(name,',',3) ,  CONCAT(substring_index(name,',',2),',') ,-1)  a3,
SUBSTRING_INDEX(substring_index(name,',',4) ,  CONCAT(substring_index(name,',',3),',') ,-1)  a4,
SUBSTRING_INDEX(substring_index(name,',',5) ,  CONCAT(substring_index(name,',',4),',') ,-1)  a5,
SUBSTRING_INDEX(substring_index(name,',',6) ,  CONCAT(substring_index(name,',',5),',') ,-1)  a6 from test

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/326732.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

如何导出Navicat的数据库连接配置

如何导出Navicat的数据库连接配置 如何导出Navicat的数据库连接配置_石头wang的博客-CSDN博客_navicat 导出配置 如何导出Navicat的数据库连接配置 背景 我们可能会在不同的电脑安装Navicat,这些连接的配置如何从一台电脑迁移到另外一条?自行备份是比较…

Spring BeanFactory 容器

转载自 Spring BeanFactory 容器 Sping 的 BeanFactory 容器 这是一个最简单的容器,它主要的功能是为依赖注入 (DI) 提供支持,这个容器接口在 org.springframework.beans.factory.BeanFactory 中被定义。 BeanFactory 和相关的…

C#开发人员应该知道的13件事情

本文讲述了C#开发人员应该了解到的13件事情,希望对C#开发人员有所帮助。 1. 开发过程 开发过程是错误和缺陷开始的地方。使用工具可以帮助你在发布之后,解决掉一些问题。 编码标准 遵照编码标准可以编写出更多可维护的代码,特别是在由多个开发…

充电提示音_iPhone如何自定义充电提示音,图文教程

昨天给小伙伴们分享了几个iOS14的充电提示音和设置方法,不过有的小伙伴可能需要设置自己喜欢的声音为充电提示音,所以今天就来教大家自定义喜欢的iOS14充电提示音。教程由于比较仔细,看起来比较长,其实很简单,主要分为…

Scanner获取用户输入

next()和hasNext() public class Demo02_Scanner {public static void main(String[] args) {//创建一个扫描器对象,用于接收键盘数据Scanner scanner new Scanner(System.in);System.out.println("使用next方式接收: ");//判断用户有没有输入字符串if …

idea Lombok插件

此文提供对于Lombok的简单使用 1、Lombok简介 Lombok能通过注解的方式,在编译时自动为属性生成构造器、getter/setter、equals、hashcode、toString方法。 2、Lombok插件安装 想要使用 Lombok,必须要安装一个 Lombok 插件,不然编辑器无法识…

复变函数画图cosz图像_用matlab绘制x=(1+cosu)cosv,y=(1+cosu)sinv,z=sinu图像?

用matlab绘制x(1cosu)cosv,y(1cosu)sinv,zsinu图像?234游戏网友 提出于 2019-07-19 07:04:26u-2*pi:0.01:2*pi;v-2*pi:0.01:2*pi;x(1cosu).*cosv;y(1cosu).*sinv;zsinu;polt3(x,y,z)xlabel(x);ylabel(y);zlabel(z);grid但是出现了:Errorusingplot3Vector…

赫夫曼编码字节数组

思路分析 代码实现 package com.atguigu.huffmancode;import com.sun.org.glassfish.external.statistics.CountStatistic; import com.sun.org.glassfish.external.statistics.StringStatistic;import java.util.*;/*** 创建人 wdl* 创建时间 2021/3/27* 描述*/ public class…

Spring ApplicationContext 容器

转载自 Spring ApplicationContext 容器 Spring ApplicationContext 容器 Application Context 是 spring 中较高级的容器。和 BeanFactory 类似,它可以加载配置文件中定义的 bean,将所有的 bean 集中在一起,当有请求的时候分配 bean。 另…

.NET Core 工具中的新内容

Visual Studio 2017 RC最近一个版本更新包括一套更新的.NET Core工具箱。这个版本带来了几项改进,包括改变了模版化、dotnet网络命令,以及许多缺陷修复。微软的Rich Lander发表了一份更新说明,陈述了.NET Core开发人员可以预期在.NET Core RC…

python binascii array('c')_详解Python中的array数组模块相关使用

初始化array实例化可以提供一个参数来描述允许那种数据类型,还可以有一个初始的数据序列存储在数组中。import arrayimport binasciis This is the array.a array.array(c, s)print As string:, sprint As array :, aprint As hex :, binascii.hexlify(a)数组配置…

你还可以续命几次?回顾DockPanel Suite项目的发展史

微软在设计Visual Studio.NET的时候汲取了之前IDE版本的各种教训,开始考虑怎样让开发人员能够快速调整多窗口的布局,灵活构建自己喜欢的日常界面。这种基于菜单条和悬浮面板的新界面也让Windows平台其他软件开发者豁然开朗,开始各种借鉴。微软…

利用赫夫曼编码进行数据解压

基本概念 代码实现 package com.atguigu.huffmancode;import com.sun.org.glassfish.external.statistics.CountStatistic; import com.sun.org.glassfish.external.statistics.StringStatistic;import java.security.AlgorithmConstraints; import java.util.*;/*** 创建人 w…

Spring Bean 定义

转载自 Spring Bean 定义 Bean 定义 被称作 bean 的对象是构成应用程序的支柱也是由 Spring IoC 容器管理的。bean 是一个被实例化,组装,并通过 Spring IoC 容器所管理的对象。这些 bean 是由用容器提供的配置元数据创建的,例如&#xff…

mysql5.7安装

MySQL 5.7 安装教程(全步骤、保姆级教程)_普通网友的博客-CSDN博客_mysql5.7的安装教程 Index of /mysql/downloads/MySQL-5.7/ | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror This application requires Visual Studio 2013 x64 Redistribut…

检测窥屏_开挂、狙击、窥屏?乱象丛生的炉石狂野天梯,到底怎么了?

今日正文1 中午吃饭时,我第二十三次诱惑牌酱跟我一起去狂野玩,在他第二十三次拒绝后,我问他为什么,他放下了筷子看着我,只说了一个字:“乱”乱?嗯,想想最近的狂野,不论是…

.NET Core log4net 使用

log4net .NET Core 版使用,log4net 2.0.7版发布也有一段时间了,从2.0.6 版开始就已经支持.NET Core。 之前有介绍NLog .NET Core版的使用,ASP.NET Core 开发-Logging 使用NLog 写日志文件。 ASP.NET Core已经内置了日志支持,可以轻松输出到控…

Spring Bean 作用域

转载自 Spring Bean 作用域 Bean 的作用域 当在 Spring 中定义一个 bean 时,你必须声明该 bean 的作用域的选项。例如,为了强制 Spring 在每次需要时都产生一个新的 bean 实例,你应该声明 bean 的作用域的属性为 prototype。同理&#xff…

Java 计算两个时间相差的天,时,分钟,秒

public static String getDateTimePoor( Date startDate ,Date endDate ) {long nd 1000 * 24 * 60 * 60;long nh 1000 * 60 * 60;long nm 1000 * 60;// long ns 1000;// 获得两个时间的毫秒时间差异long diff endDate.getTime() - startDate.getTime();// 计算差多少天lo…