数据库
首页 > 数据库> > 截取sql字符

截取sql字符

作者:互联网


原来:aa–bb–cc
截取后:aa–bb

select reverse(substring(reverse(字段),CHARINDEX(’–’,reverse(字段))+2 ,LEN(字段) )) from table where 条件=‘abc’

 

--取反
select progressrecord from o_ptaskplan_progress
--2021-04-27 3%;2021-04-27 5%;2021-04-28 51%;2021-06-29 52%;2021-06-29 53%;
select reverse(progressrecord) from o_ptaskplan_progress
--;%35 92-60-1202;%25 92-60-1202;%15 82-40-1202;%5 72-40-1202;%3 72-40-1202

 

--去掉所有 ;
select replace(progressrecord , ';','') from o_ptaskplan_progress
--2021-04-27 3%2021-04-27 5%2021-04-28 51%2021-06-29 52%2021-06-29 53%

标签:字符,06,04,--,截取,1202,2021,sql,select
来源: https://www.cnblogs.com/w852894903/p/15691887.html