MySql教程
MySql用户管理
MySQL数据库
MySql表格和视图
MySQL查询
MySQL索引
MySQL子句
MySQL授权
MySql控制流
MySQL条件
MySQL连接
MySQL键
MySQL触发器
MySQL聚合函数
MySQL常用
MySQL正则表达式
MySql差异性

MySQL SUBSTR()函数

MySQL SUBSTR()函数

substr()是MySQL的String函数。此函数从给定的字符串返回子字符串。

语法

select substr(Str, pos);
Select substr(Str from pos);
Select substr(Str, pos, len);
Select substr(Str from pos for len);

参数:

Str : 主字符串
len: 子字符串的长度
pos: 从给定的字符串开始定位子字符串。

示例1

Select substr('lidihuo', 5);
输出:

MySQL字符串SUBSTR()函数

示例2

Select substr('lidihuo' from 6);
输出:

MySQL字符串SUBSTR()函数

示例3

Select substr('lidihuo', 8,3);
输出:

MySQL字符串SUBSTR()函数

示例4

Select substr('lidihuo' from 1 for 4);
输出:

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