(a.order_status = 'N' or a.order_status = 'I') and a.card_status = 'Y' 
不用or看看

解决方案 »

  1.   

    还有,你取那么多出来做什么
    不能用limit限制一下么
      

  2.   

    substring(a.reg_date,1,8) >= '20050801' and substring(a.reg_date,1,8) <= '20050801'
    只在substring(a.reg_date,1,8) = '20050801'时成立
    而substring的起始偏移是从0算起的,即便reg_date存放有字符型的日期,条件也不会被满足你根本得不到结果,哪里有速度可言呢?
      

  3.   

    同意楼上的
    LZ的SQL实在看的有问题!
      

  4.   


    不知道这样能否符合你的要求,同时给a.id,a.server_code,b.id,c.code字段添加索引select count(a.*) 
    from tbl_order a join tbl_member b on a.id=b.id 
    join tbl_server c on a.server_code=c.code 
    where a.reg_date like '20050801%' and a.card_status = 'Y' and (a.order_status = 'N' or a.order_status = 'I')
      

  5.   

    谢谢大家!给我回复!!真的谢谢你们!可还是成功!loveflea(coolwind) ====〉ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresponds to your MySQL server version for the right syntax to use near '*) 
    from tbl_order a join tbl_member b on a.id=b.id 
    join tbl_s出来这样的出错!
      

  6.   

    我在该了一下!可以了!^_^; 谢谢大家了!份一定给!select count(a.id) 
    from tbl_order a left join tbl_member b,tbl_server c on a.id=b.id and a.server_code=c.code 
    where a.reg_date like '20050801%' and a.card_status = 'Y' and (a.order_status = 'N' or a.order_status = 'I')