小弟需要筛选一组号码 共两个问题 
举例 现有号码如下
230
231
232
233
234
235(实际好多个号码 什么组合都有)
1.怎么提取以23开头的全部号码?  
2.假设只提取230 231 232 233 不提取234以后以及其他的号码 有通用的语句吗?还是要单独筛选出来?
请各位达人帮我把这2个问题所需语句写出来 小弟新手 研究没几天 恳请赐教~!

解决方案 »

  1.   

    只有一个表~列名就叫 col 吧
      

  2.   

    1、select col from tabel1 where col like '23%'2、select col from tabel1 where col like '23%' and col<'234'
      

  3.   

    1、select 字段名 from 表名 where 字段名 like '23%'2、select 字段名 from 表名 where 字段名 >'230' and 字段名<'234'
      

  4.   

    230
    231
    232
    233
    234
    235(实际好多个号码 什么组合都有)
    1.怎么提取以23开头的全部号码?  
    2.假设只提取230 231 232 233 不提取234以后以及其他的号码 有通用的语句吗?还是要单独筛选出来?
    =============
    1.   like '23%'
    2.  >='230' and <='233'
      

  5.   

    select * from table where substring(colum,1,2) = '23'
      

  6.   

    1.select * from table where col like '23%'
    2.select * from table where col like '23[0-3]%'
      

  7.   

    create table #num
    (
      num int
    )insert into #num
    select 230 union all select 
    231 union all select 
    232 union all select 
    233 union all select 
    234 union all select 
    324 union all select 
    235select * from #num where num like '%23%'select * from #num where num like '23[0-3]%'
    drop table #num
      

  8.   

    num
    230
    231
    232
    233
    234
    235num
    230
    231
    232
    233
      

  9.   

    select * from #num where num like '23%'
      

  10.   

    DECLARE @SQL CHAR(100),@A CHAR(6),@B CHAR(1),@C CHAR(1),@a1 char(5)
    SET @A='102563'
    SET @B='0'
    SET @C='3'
    set @a1=left(@a,5)SET @SQL='SELECT * FROM EMPLOYEES WHERE EMPLOYID LIKE '''+RTRIM(@A1)+'['+RTRIM(@B)+'-'+RTRIM(@C)+']%'''
    EXEC (@SQL)
      

  11.   

    select * from table_name where col like '23[0-3]%'
      

  12.   

    select * from #num where num like '%23%'select * from #num where num like '23[0-3]%'
      

  13.   

    第二个问题这样写:
    like '23[0-3]%'