Python语言基础
Python语言进阶
Python数据结构

MySQL SUBSTRING_INDEX()函数

substring_index()是MySQL的String函数。此函数在计数到达分隔符之前从给定的字符串(str)返回一个子字符串。

语法

select substring_index(str, delim, count);

参数:

str : 主字符串
delim : 要搜索的字符串
count: 搜索delim的次数

返回:

此函数返回字符串的子字符串

示例1

Select substring_index('www.lidihuo.com','.',3);
输出:

MySQL字符串SUBSTRING_INDEX()函数

示例2

Select substring_index('www.lidihuo.com','.',2);
输出:

MySQL字符串SUBSTRING_INDEX()函数

示例3

Select substring_index('www.lidihuo.com','.',1);
输出:

MySQL字符串SUBSTRING_INDEX()函数

示例4

Select substring_index('www.lidihuo.com','.',-1);
输出:

MySQL字符串SUBSTRING_INDEX()函数

示例5

Select substring_index('www.lidihuo.com','.',-2);
输出:

MySQL字符串SUBSTRING_INDEX()函数
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4