表Table 1
字段SendDate    文本类型 
值,"1-2","3-4","5-6","7-8","9-10","11-12"sSQL := 'select * from Table1 where SendDate >='1-2'and SendDate <='11-12'';这样查询就会出错,因为"11-12"<"1-2" 有什么方法在数据库内容不对的情况下,查询正确呢????

解决方案 »

  1.   

    应该是:
    sSQL := 'select * from Table1 where SendDate >=''1-2'' and SendDate <=''11-12''';
      

  2.   

    --楼主用的是什么数据库,这是oracle下的结果
    --测试数据
    create table table1( SendDate varchar2(4000));
    insert into table1 values('"1-2","3-4","5-6","7-8","9-10","11-12"');
    --执行查询
    select 
    substr( SendDate,instr(SendDate,'"1-2"',1),instr(SendDate,'"11-12"',1)+length('"11-12"') )
    from table1
    --输出结果
    "1-2","3-4","5-6","7-8","9-10","11-12"
      

  3.   

    谢谢大家,我用的是Access数据库!
      

  4.   

    sqlserver中应该是这样的吧,没测试
    select 
    SUBSTRING( SendDate,CHARINDEX('"1-2"',SendDate),CHARINDEX('"11-12"',SendDate)+len('"11-12"') )
    from table1
      

  5.   

    access下
    select
    mid( SendDate,instr(SendDate,'"1-2"'),instr(SendDate,'"11-12"')+len('"11-12"') )
    from table1
      

  6.   

    hongqi162(失踪的月亮)  真是厉害啊。