mysql链表查询

mysql链表查询查不到对应的最新一条数据

SELECT COUNT(DISTINCT(d.SN))
FROM DeviceInfo d
LEFT JOIN 
(SELECT de.SN,de.deallType,de.orderID FROM DeviceDealOrders de WHERE NOT EXISTS(SELECT 1 FROM DeviceDealOrders WHERE SN=de.SN AND creatorDate>de.creatorDate AND sysStatus=1)AND de.sysStatus=1)  dorder 
ON(d.SN=dorder.SN)
LEFT JOIN
(SELECT sp.SN,sp.shipmentDate,sp.recipientName,sp.remark  FROM Shipment sp WHERE NOT EXISTS(SELECT 1 FROM Shipment WHERE SN = sp.SN AND creatorDate>sp.creatorDate AND sysStatus=1) AND sp.sysStatus=1) Shipm
ON(d.SN = Shipm.SN)
WHERE d.sysStatus=1 AND (d.distributorID='' OR  ISNULL(d.distributorID))


你可能感兴趣的:(mybatis)