首页 > 代码库 > 数据库常用函数整理

数据库常用函数整理

1.字符串拼接函数concat(str1,str2)
str1=abc;
str2=efg;
concat(str1,str2)的结果:abcefg
 
2.字符串截取函数substr(str1,start,length),left(str1,length),right(str1,length)
str1=abcdefg
substr(str1,1,3)=abc
left(str1,3)=abc
right(str1,3)=efg
 
3.sql选择判断
select case when str1 is null then abcd 
                  when str1=123 then efgh
                  else who
           end from tablename;
 
实例:
SELECT CASE WHEN TRANS_REMARK IS NOT NULL THEN LEFT(TRANS_REMARK,6) ELSE NEXTVAL FOR UPPSEQ1,CORE AS FUNDCHANNELCODE,TRANS_SEQNO,CONCAT(LEFT(TRANS_DATE,4),RIGHT(TRANS_REMARK,10)),TRANS_STATUS FROM OT_TRANS;

 

 

数据库常用函数整理