创建测试表及数据
1
2
3
4
5
6
7
8
9
|
create table test ( name varchar2(10)); insert into test values ( ‘2-15‘ ); insert into test values ( ‘2-33‘ ); insert into test values ( ‘2-3‘ ); insert into test values ( ‘12-8‘ ); insert into test values ( ‘12-22‘ ); insert into test values ( ‘12-3‘ ); |
执行
1
|
select name ,substr( name ,1,instr( name , ‘-‘ )-1) 前,substr( name ,instr( name , ‘-‘ )+1,length( name )-instr( name , ‘-‘ )) 后 from test |
原文:http://www.cnblogs.com/fkeyta/p/5856129.html