阅读量:0
- 示例一:提取字符串中的子串
SELECT SUBSTR('Hello World', 1, 5) AS Result;
输出结果为:Hello
- 示例二:获取字段值的子串
SELECT SUBSTR(column_name, 3) AS Result FROM table_name;
- 示例三:获取字段值的子串,并指定长度
SELECT SUBSTR(column_name, 3, 5) AS Result FROM table_name;
- 示例四:获取字段值的子串,并根据条件筛选
SELECT SUBSTR(column_name, 3) AS Result FROM table_name WHERE column_name LIKE '%pattern%';
- 示例五:使用SUBSTR函数进行字符串拼接
SELECT SUBSTR('Hello', 1, 3) || SUBSTR('World', 1, 3) AS Result;
输出结果为:HelWor