SELECT Line
FROM sewing_effi
WHERE DT='$dt'
ORDER BY Line ASC"
的数据类型是什么 DT ? (请提供 SHOW CREATE TABLE ) 假设 DT 是一个 DATE ,那么你需要 INDEX(DT, Line) 为了提高效率。 为此:
SELECT buyer.Buyer,ordr.ordr,ordr.Ship_Date,colour.Colour,sewing_effi.OP,
sewing_effi.HEL,sewing_effi.Target,sewing_effi.TWH,sewing_effi.Line,
sid_cutting_inventory.DT,
SUM(cutting_inventory.qc_pass) AS Input,
SUM(sewing_output.QC_Pass) AS Toutput, SUM(sewing_output.Recieved) AS Recv
FROM cutting_inventory
INNER JOIN sid_cutting_inventory
ON cutting_inventory.SID=sid_cutting_inventory.SID
LEFT JOIN buyer ON cutting_inventory.Buyer=buyer.CBuyer
LEFT JOIN ordr ON cutting_inventory.Buyer=ordr.CBuyer
AND cutting_inventory.Ordr=ordr.COrdr
INNER JOIN colour ON cutting_inventory.Buyer=colour.CBuyer
AND cutting_inventory.Ordr=colour.COrdr
AND cutting_inventory.Colour=colour.CColour
LEFT JOIN sewing_output ON sewing_output.Barcode=cutting_inventory.Barcode
JOIN sewing_effi ON sewing_effi.Line=sid_cutting_inventory.Line
WHERE sewing_effi.Line ='$li'
AND sewing_effi.DT='$dt'
AND ordr.Ship_Status='0'
AND sid_cutting_inventory.Challan_Close_SS='0'
AND sid_cutting_inventory.DT NOT BETWEEN '2017-01-31 7:00:00'
AND '2018-03-31 23:00:00'
GROUP BY sewing_effi.Line, buyer.Buyer, ordr.ordr,colour.Colour
ORDER BY sewing_effi.Line"
)
2条答案
按热度按时间kupeojn61#
安装了32位版本的mysql。我附上了一些表的快照并进行了解释。我想你会很容易发现我的问题。expalincutting\u inventory tableswing\u effi tableswing\u output tableid\u cutting\u inventory table输出表ID\u切割\u库存表
wixjitnu2#
不要使用mysql接口!
的数据类型是什么
DT
? (请提供SHOW CREATE TABLE
)假设
DT
是一个DATE
,那么你需要INDEX(DT, Line)
为了提高效率。为此:
我觉得混合起来很混乱
LEFT JOIN
以及INNER JOIN
. 请提供EXPLAIN SELECT ...
我来猜猜看。您是否安装了32位或64位版本的mysql?