mysql操作

来源:互联网 发布:mac qq群文件在哪 编辑:程序博客网 时间:2024/06/05 15:48


1 字符串截取

select max(substring(sSequence,2)+0) as sSequence from org where sOrgKindID='ogn';


sSequence 值为/001,/002,/0011,此时需要取出最大值,并返回,应该返回11


substring(sSequence,2) 从第二位开始截取:   001,002,0011,之后

substring(sSequence,2)+0,  从字符串变整数 1,2,11

max下取最大值



2 select给多个变量赋值

    set  @tmPsFName='';
        set  @tmPsFCode='';
        set  @tmPsFID='';
        set  @tmPsSequence='';  
        
        select sFName,sFCode,sFID,sSequence into @tmPsFName,@tmPsFCode,@tmPsFID,@tmPsSequence from sa_oporg where sID=csParent;


原创粉丝点击