比如,表中table1 中 有一个字段title  
title 的内容为:  虚拟社区提供的每日一文件我想通过sql显示 title内容的前面4个字,应该如何写的
谢谢!

解决方案 »

  1.   

    select left(title,4) from table1
      

  2.   

    当您的问题得到解答后请及时结贴.
    http://topic.csdn.net/u/20090501/15/7548d251-aec2-4975-a9bf-ca09a5551ba5.html
    http://topic.csdn.net/u/20100428/09/BC9E0908-F250-42A6-8765-B50A82FE186A.html
    http://topic.csdn.net/u/20100626/09/f35a4763-4b59-49c3-8061-d48fdbc29561.html8、如何给分和结贴?
    http://community.csdn.net/Help/HelpCenter.htm#结帖
      

  3.   

    select left(title,4) from table1 where strlen(title)<>4
      

  4.   

    [Quote=引用 4 楼 xiaoyangge 的回复:]
    select left(title,4) from table1 where strlen(title)<>4
    [/Quote
    +1
      

  5.   

    -1 
    这个会漏掉标题只有四个字符的行啦,不是所有的行了。实际上 left 函数对参数一的长度是没有限制的,多于或少于或等于截取长度都能正常工作。
      

  6.   

    不好意思没有strlen()这个函数,这个是不是php的?
    是不是要改为:
    select left(content,4)  from blog where length(content)<>4