LEFT JOIN 应该显示左表上的所有行,但是在运行以下查询时,我只获得计数为 1 或更多的位置值。请有人给我一些关于我可能出错的地方的指导:
SELECT places.placeId,
placeName,
COUNT(orderId) AS orderCount
FROM places
LEFT JOIN orders
ON places.placeId = orders.placeId
WHERE places.companyId = 1
AND stateId = 1
AND orderstateId = 1
AND orderName NOT LIKE 'Delivery%'
GROUP BY places.placeId,
places.placeName
ORDER BY orderCount DESC,
placeName ASC
提前致谢