select * from db.mdb where (cast(number as integer) between '+edit1.text+'    and '+edit2.text+')')

解决方案 »

  1.   

    select * from db.mdb where number between :x and :y
     
       query1.ParamByName(x).asinteger := strtoint(edit1.text);
       query1.ParamByName(y).asinteger := strtoint(edit2.text);
      

  2.   

    ssql:='select * from db.mdb where convert(int,number) between :x and :y';
    query1.sql.add(ssql);
    query1.parambyname('x').asinteger:=strtoint(edit1.text);
    query1.ParamByName('y').asinteger := strtoint(edit2.text);
      

  3.   

    老人家,
    你的number好象是个字符串类型的,
    你要给它加引号才可以啊!
      

  4.   

    你这个问题出在对between的不了解!
    这种情况可以写成select * from db.mdb where number between '+#39+edit1.text+#39+' and '+#39+edit2.text+#39+',因为是字符型,所以你必须要加引号!
      

  5.   

    楼上大哥,BETWEEN AND 之间是整型哦.是你不了解啊.
      

  6.   

    老鱼,提示!!!!!!!!!!!!!
    怎么定义CAST啊???????????
      

  7.   

    老千!!!!!!也提示!!!!!!!!CAST!!!!!!!
      

  8.   

    Local SQL帮助中
    Converts specified value to the specified data type.CAST(column_reference AS data_type)DescriptionUse CAST to convert the value in the specified column to the data type specified. CAST can also be applied to literal and calculated values. CAST can be used in the columns list of a SELECT statement, in the predicate for a WHERE clause, or to modify the update atom of an UPDATE statement.The Data_Type parameter may be one of most column data type applicable to the table type used: CHAR, INTEGER, NUMERIC, and so on. Certain column types cannot be used as the source or target data types: BLOB, MEMO, and BYTES.The statement below converts a Paradox TIMESTAMP column value to DATE.SELECT CAST(SaleDate AS DATE)FROM ORDERSConverting a column value with CAST allows use of other functions or predicates on an otherwise incompatible data type, such as using the SUBSTRING function on a DATE column.SELECT SaleDate,  SUBSTRING(CAST(CAST(SaleDate AS DATE) AS CHAR(10)) FROM 1 FOR 1)FROM OrdersWhen applied to retrieved data of a SELECT statement, the effect is transient and does not affect stored data. When applied to the update atoms of an UPDATE statement, the effect is persistent and permanently converts the case of the stored values.Note: the CAST function cannot be used with memo or BLOB columns.
    另外你当字符串用不也行吗 '026' 当然应比 '025'大了,转换做什么
      

  9.   

    是啊,可惜我的不是paradox而是access.
      

  10.   

    select * from db.mdb where (number(number as integer) between '+edit1.text+'    and '+edit2.text+')')access 里似乎也有类似于cast的 函数 好象是number 试试看吧 
      

  11.   

    对于字符串类型是可以判断大小的,把SQL改为:
    'select * from db.mdb where number>'''+Edit1.Text+'''and number<'''+Edit2.Text+'''';
      

  12.   

    select * from db.mdb where number between case(x as char(3)) and  cast(y as char(3))    :)Between And 里可以用字符串,:D
      

  13.   

    select * from db.mdb where convert(int,number) between x and y就可以了。