select left(fieldname,50) from tablename

解决方案 »

  1.   

    select substring('我有一张表,有一个字段存一些用户发的文章但是我现在查询只想显示这些文章的前50个字(有的文章总共也不到50字)怎么做呢?最好是在数据库这边做,不知道sql语句应该怎么写?谢谢
    ',1,50)
      

  2.   

    declare @str varchar(100)
    set @str='123456789012345678901234567890'
    select substring(@str,1,10)   ---取前10个字符--结果-------------------- 
    1234567890
      

  3.   

    select left('text',50) from ....
      

  4.   

    select substring(文章,1,50) as 文章 from YourTable where len(文章) >= 50
    union all
    select 文章 from YourTable where len(文章) < 50
      

  5.   

    我是用的text的字段,所以好像用left不行
    不过用substring可以
    谢谢了