SUBSTR() 函数从字符串中提取子字符串(从任意位置开始)。
SUBSTR(
string,
start,
length)
或者:
SUBSTR(
string FROM
start FOR
length)
Parameter | Description |
---|---|
string | Required. The string to extract from |
start | Required. The start position. Can be both a positive or negative number. If it is a positive number, this function extracts from the beginning of the string. If it is a negative number, this function extracts from the end of the string |
length | Optional. The number of characters to extract. If omitted, the whole string will be returned (from the start position) |
工作于: | 从 MySQL 4.0 开始 |
---|
从列中的文本中提取子字符串(从位置 2 开始,提取 5 个字符):
SELECT SUBSTR(CustomerName, 2, 5) AS ExtractString
FROM Customers;
亲自试一试 »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!