找出表明为Table1中处在ID字段中的第1-200条记录中Name字段包含w的所有记录
并对找到的结果按年龄age升序排序各位帮一哈啦,检验一下看看我写的是不是对的,不好意思贴,谢啦!

解决方案 »

  1.   

    select * from Table1 where ID between 1 and 200 and charindex('w',Name)>0 
    order by age
      

  2.   

    select * from Table1 where ID >=1 and ID<= 200 and charindex('w',name)>0 
    order by age
      

  3.   

    ID字段第1到200, 你的ID是按照数字排序吗?如果是的话1楼就可以了如果不是的话,那就麻烦了select top 200 * to # from table1
    select * from #
    where charindex('w',Name)>0 drop table #
      

  4.   

    哦,忘记排序了,
    select top 200 * to # from table1
    select * from #
    where charindex('w',Name)>0 
    order by age asc
    drop table #
      

  5.   

    ID字段中的第1-200条记录,我的理解就是前200条纪录select * from 
      (select top 200 * from Table1 order by uid)tmp 
    where name like '%w%' order by age以前不知道charindex函数
    随便问一下用 like 关键字和用 charindex 那个效率高一点
    谢谢!
      

  6.   

    select * from Table1 where ID between 1 and 200 and name like '%w%'
    order by age
      

  7.   

    select * from Table1 
    where (ID between 1 and 200)
     and name like '%w%'
    order by age