L
LukyDee
Unregistered / Unconfirmed
GUEST, unregistred user!
目的是查订单明细:<br> 客户表:Customers ,主键为CusID<br> 订单主表:OrderMst,主键为OrderSNO<br> 订单从表:OrderDtl <br>表和表之间的约束:Customers.CusID<--OrderMst.CusID<br> OrderMst.OrderNO<--OrderDtl.OrderNO<br><br>----以下为查询语句:-----------------------------------------------------<br><br>SELECT Customers.CusID,Customers.CusName, OrderMst.OrderNO, OrderMst.OrderDate, OrderMst.CusID,<br> OrderDtl.ProductID<br>FROM Customers INNER JOIN<br> OrderMst ON Customers.CusID = OrderMst.CusID INNER JOIN<br> OrderDtl ON OrderMst.OrderNO = OrderDtl.OrderNO<br><br>执行结果6万行数据,不用1秒;<br>加了以下日期范围:<br>whereOrderMst.OrderDate between '2008-08-01' and '2008-08-10'<br><br>执行结果是:1990行,35秒<br>-------------------------------------------------------------------------------<br><br>检查数据发现,订单主表的OrderDate就没有规律,有前有后的,如:<br>OrderNO OrderDate <br>00001 2008-08-01<br>00002 2008-08-01<br>00003 2008-07-31<br>00004 2008-08-01<br>..........<br>00102 2008-08-03<br>00103 2008-08-02<br>00104 2008-08-02<br><br>请教下优化的查询方法?