select 字段 from 表;
问题:
字段有时候很长,有时候很短,我想就显示4个字符,多于4个的,后面带上...。不多的或者少于4个的,就不带...
这个sql语句怎么完善
谢谢

解决方案 »

  1.   

    查出来了后
    if (字段.length>4)
    {
       字段.substring(0,4)+"...";
    }
    else
    {
       字段
    }
      

  2.   

    select   字段[1,4]  from   表; 
      

  3.   

    select
    case when length(column_1) > 4 then concat(substr(column_1,1,4),'...') else column_1 end
    from table_1
      

  4.   


      select 字段=(case len(字段)/4 when 0 then 字段 else 字段+'...' end) from 表
      

  5.   

    忘了截取了,改正下:  select 字段=(case len(字段)/4 when 0 then 字段 else left(字段,4)+'...' end) from 表