我感觉是substr(user_name, 0,1)这个函数参数错误。改成substr(user_name,1,1)没有测试。

解决方案 »

  1.   

    你自己查下 SUBSTR() 第一个参数是从0开始还是从1开始的咯我个人感觉都可以,
      

  2.   

    我感觉是substr(user_name, 0,1)这个函数参数错误。改成substr(user_name,1,1)没有测试。substr(user_name,1,1)这个是对的。
      

  3.   

    我测试的结果是一样,两个都可以。
    而且百度上:substr(字段,a,b)
    a代表第几个位置
    b代表长度
    0和1的效果一样
      

  4.   

    Substr(char, startpos, length),Substr参数length字符集也有关系哦
      

  5.   


    substr( string, start_position, [ length ] )
    string:is the source string.
    start_position:is the position for extraction. The first position in the string is always 1.
    length:is optional. It is the number of characters to extract. If this parameter is omitted, substr will return the entire string.Note:
    1.If start_position is 0, then substr treats start_position as 1 
    (ie: the first position in the string).
    [如果起始位置为0,那么substr函数将其当做1处理,也就是字符串(string)的第一个位置]
    2.If start_position is a positive number, 
    then substr starts from the beginning of the string.
    3.If start_position is a negative number, 
    then substr starts from the end of the string and counts backwards.
    4.If length is a negative number, then substr will return a NULL value.For example:
    substr('_yeexunOnCSDN',8)    char_return 'OnCSDN'
    substr('_yeexunOnCSDN',10)   char_return 'CSDN'
    substr('_yeexunOnCSDN',8,2)  char_return 'On'
    substr('_yeexunOnCSDN',-4,4) char_return 'CSDN'
    substr('_yeexunOnCSDN',0,7)  char_return '_yeexun'
    substr('_yeexunOnCSDN',1,7)  char_return '_yeexun'
    substr('_yeexunOnCSDN',0,1)  char_return '_'
    substr('_yeexunOnCSDN',1,1)  char_return '_'
    substr('_yeexunOnCSDN',0,2)  char_return '_y'
    substr('_yeexunOnCSDN',1,2)  char_return '_y'