表:temp
  start          end        MYName
  1                100       我
  100              300       你
   500              1000     他
  用户输入:210   我怎么返回   “你”
  selent MYName  from  temp 
 where ??

解决方案 »

  1.   

    declare @parm int,
            @myname varchar(20)set @parm = 210select @myname = myname from temp where @parm between start and end
      

  2.   

    selent MYName  from  temp 
     where 210 between start and [end]
      

  3.   

    select myname from table where @inputnum between start and end
      

  4.   

    --用户输入100你输出什么?declare @temp table
    (
    start int,
    [end] int,
    MYName varchar(2)
    )
    insert into @temp
    select 1,100,'我' union all
    select 100,300,'你' union all
    select 500,1000,'他'declare @a int
    set @a=210
    select myname
    from @temp
    where start<@a and [end]>=@aset @a=600
    select myname
    from @temp
    where start<@a and [end]>=@a/*
    myname 
    ------ 

    myname 
    ------ 

    */
      

  5.   

    declare @t table( start int,[end] int,myname varchar(10))
    insert @t select 1,100,'我'
    union all select 100,300,'你'
    union all select 500,1000,'他'select myname
    from @t
    where 210 between start and [end]
      

  6.   

    declare @a int
    set @a = 210
    selent MYName  from  temp 
     where @a between start and [end]
      

  7.   

    先回贴1>取得用户输入值
    2>组合成SQLDim strTmp as string
    strTmp=trim(用户输入值框)strTmp='SELECT MyName from  temp where " + strtmp + ' between start and [and] 'Ado.connection.execute(strtmp)
    ----------------------------------------------------
    再接分.
      

  8.   

    jf--------
    declare @t table( start int,[end] int,myname varchar(10))
    insert @t select 1,100,'我'
    union all select 100,300,'你'
    union all select 500,1000,'他'declare @a int
    set @a = 210
    select myname  from  @t 
    where @a between start and [end]
      

  9.   

    selent MYName from temp
    where 210 between start and [end]不就搞定了吗,
      

  10.   

    俺也来接分.
    select MYNAME FROM temp 
     where @InputNumber BETWEEN start and end
      

  11.   

    selent MYName  from  temp 
     where 210 between start and [end]
      

  12.   

    --我的应该最符合要求
    declare @temp table
    (
    start int,
    [end] int,
    MYName varchar(2)
    )
    insert into @temp
    select 1,100,'我' union all
    select 100,300,'你' union all
    select 500,1000,'他'
    declare @InputValue int
    declare @MyName varchar(2)set @InputValue=600select @MyName=MyName from @temp where(@InputValue>=Start) and (@InputValue<[End])print @MyName
      

  13.   

    用case when 语句即可实现
      

  14.   

    selent MYName from temp
    where start < 210 and end >210
      

  15.   

    jf
    select MYName  from  temp 
     where 210 between start and [end]
      

  16.   

    select MYNAME FROM temp 
     where @InputNumber BETWEEN start and end