由于每个人录入习惯的不同,我的数据库里面,人员表的名字很乱查询出来的结果,例如:    张三(一班班长) ,  张三  , 张三(一班) , 王五(一班班长) ,王五
我想要将查询出来的结果“张三(一班班长)”,统一截取成 “张三”表达不是很清晰,希望大家能帮帮忙!

解决方案 »

  1.   

    Update table biao set name = substring(name,1,2)
    Where name = '张三(一班班长'
      

  2.   

    "张三(一班班长)".split('(')[0]
      

  3.   

    捣乱一下,难道是?Update table biao set name = substring(name,1,2) Where name like '张三%'
      

  4.   

    好吧 给你弄出来了
                string StudentName = "张三(一班班长)";
                StudentName = StudentName.Replace("(","(").Split('(')[0];
    快去试试吧
      

  5.   

    你确定一定是用“(”的吗
    是的话
    Update table biao set name = substring(name,1,CharIndex('('))
    Where name = '张三(一班班长'
      

  6.   

    t1="张三(一班班长) , 张三 , 张三(一班) , 王五(一班班长)";
    string[] s =t1.Split(',');
    foreach(string st in s)
    {
      Console.WriteLine(st.Split('(')[0]);
    }
      

  7.   

    表中数据为:
    001 张三         2010-01-01
    002 张三(一班班长) 2010-03-01
    003 李四         2010-05-01
    004 王五(二班班长) 2010-07-01执行结果:001 张三 2010-01-01
    002 李四 2010-03-01
    003 李四 2010-05-01
    004 王五 2010-07-01SQL:
    SELECT case when StudentName like '%(%' then
    substring(StudentName,1,convert(int,charindex('(',StudentName))-1 ) else StudentName end a FROM tb_Student 
    那个SQL的作用是如果StudentName 包含了"("就找到"("的位置 然后获取它前面的内容  要是不包含 就直接取值
      

  8.   

    SQL:
    SELECT StudentNo,case when StudentName like '%(%' then
    substring(StudentName,1,convert(int,charindex('(',StudentName))-1 ) 
    else StudentName end StudentName,
    InTime FROM tb_Student 
      

  9.   

    各位辛苦了,kevin_cheung 兄完完全全解决了我的问题。嘿嘿~
      

  10.   

    先trim一下,然后从左括号上做文章就可以截取了