A.date1>A.date2 这个我觉得快不了,因为这个是会用全表扫描的。建议新增一个字段,比如flags,然后update一下这个字段,如果A.date1>A.date2  那么就是1,否则就是0.:update a
set = case when date1>date2 then 1 else 0 end
这样,查询的时候,给这个flag字段建一个索引,速度就快了:select * from A where flag= 1

解决方案 »

  1.   

    不行啊 那个表A中的DATA2其实是别的表里面left join 过来的字段有什么办法吗?
      

  2.   

    select * from a 
    left join b
    where a.kahaoid=b.kahaoid and a.xiaofeidate>b.shengjidate 
     (a表为消费表,b表为卡号表,a中为消费时间,b中为卡变成VIP时间)
    就是要选取A表里面表示VIP消费的记录,SQL上面能改吗?
      

  3.   

    不要用left join,改为inner join