select gi_id,'出售' as bs_name,left(gi_title,30) as gi_title,'分类暂无' as ss_name,gi_price,gi_click,gi_date,gi_time
from t_goods_info
where ss_id is null and buyorsell='← 卖出'如何通过上述SQL语句实现gi_title字数>=30后,在后面添加上“...”?

解决方案 »

  1.   

    case when strlen(gi_title)>= 30 then left(gi_title,30)+'...' else gi_titleend 
      

  2.   

    是替换
    left(gi_title,30) as gi_title
    吗?
      

  3.   

    select gi_id,'出售' as bs_name,case when strlen(gi_title)>= 30 then left(gi_title,30)+'...' as gi_title,'分类暂无' as ss_name,gi_price,gi_click,gi_date,gi_time
    from t_goods_info
    where ss_id is null and buyorsell='← 卖出'
      

  4.   

    select gi_id,'出售' as bs_name,(case when len(gi_title)>= 30 then left(gi_title,30)+'...' else gi_title end) as gi_title,'分类暂无' as ss_name,gi_price,gi_click,gi_date,gi_time
    from t_goods_info
    where ss_id is null and buyorsell='← 卖出'strlen()应该为len() 其他的都正确 ,谢谢各位