表table1中有三个字段,其中d1,d2代表数据的起始范围,假如有一个Edit1中的文本,我想在table1
找到包含这个文本数据范围的记录,请问sql语句应该怎样写?可用参数写假如Edit1文本传递的参数是
aatable1id d1 d2 1 40 49
2 50 59
3 60 69
4 70 79

解决方案 »

  1.   

    select * from biao where d1 <= aa and d2 >= aa
      

  2.   

    select top 1 * from (select max(d1) from table1 where d1 <= aa and d2 >= aa) as B
      

  3.   

    commandtext:='Select * from table1 Where :aa<=d2 and :aa>=d1';
    parameter.ParamByName('aa').Value:=StrToInt(Edit1.text);
      

  4.   

    'select * from biao where d1 <= '+quotedstr(Edit1.text)+' and d2 >= 'quotedstr(Edit1.text)
      

  5.   

    select * from table1  where d1<=strtoint(edit1.text) and strtoint(edit1.text)<=d2
      

  6.   

    g_sql:='select * from table1  where d1<='+edit1.text+' and '+edit1.text+'<=d2';
    cds_bss1.CommandText :=g_sql;運行的結果是
     'select * from table1  where d1<=67 and 67<=d2'
    這就可以了啊!