dear i have below query to count how many spams for each user and the total orders
i did the left join because not all orders have a spam
select users.firstName,users.lastName,users.Id,users.phoneNumber,count(CASE
WHEN comments.`commentType` = "spam" THEN 1 ELSE NULL END) as countSpam,
count(`orders`.`id`) as totalOrder
from `orders`,users,providers
LEFT JOIN comments ON `orders`.`id`= `comments`.`commentableId`
where
`orders`.`providerId` = `providers`.id
and
users.id = `providers`.userId
and
`orders`.`createdAt` >= (CURDATE() - INTERVAL 7 DAY)
GROUP BY users.id
ORDER BY countSpam DESC;
am getting the below error from mysql
Unknown column 'orders.id' in 'on clause'
What is the issue here ? i did the LEFT JOIN correct based on old query working fine