MySQL: SUBSTR( ), SUBSTRING( )Oracle: SUBSTR( )SQL Server: SUBSTRING( ) 最常用到的方式如下 (在这里我们用 SUBSTR( ) 为例): SUBSTR (str, pos) 由 <str> 中,选出所有从第 <pos> 位置开始的字元。请注意,这个语法不适用于 SQL Server 上。 SUBSTR (str, pos, len) 由 <str> 中的第 <pos> 位置开始,选出接下去的 <len> 个字元。 假设我们有以下的表格: Geography 表格
例1 SELECT SUBSTR (Store_Name, 3) FROM Geography WHERE Store_Name = 'Los Angeles'; 结果: 's Angeles' 例2 SELECT SUBSTR (Store_Name, 2, 4) FROM Geography WHERE Store_Name = 'San Diego'; 结果: 'an D' Linux实测如下: |