I have these 3 tables
users [ id , username, password ]
logs [ id, user_id, action ]
user_propeties [ id, user_id, prop_name, prop_value ]
I want to select All the user's columns with the Count(logs.id) and count(user_propeties.id) Only where prop_value IS NULL from the 2 tables depending on the user id
I have the following query
SELECT t1.*, count(t2.`id`) as total_logs,count(t3.`id`) as total_propeties
FROM `users` t1
LEFT JOIN `user_propeties` t2
ON t1.`id` = t2.`user_id` AND ISNULL(t2.`prop_value`)
LEFT JOIN `logs` t3
ON t3.`user_id` = t1.`id`
GROUP BY t1.id
ORDER BY t1.id DESC
Which returns rows but with wrong count value. What i am doing wrong? Thank you