Slide 18
Slide 18 text
·ͣݱঢ়
Ҋ݅ͱ௨Λ+0*/͍ͯͨ͠
SELECT
orders.*,
SUM(IF(notifications.id IS NULL, 0, 1))
AS unread_count
FROM `orders`
LEFT JOIN notifications
ON notifications.order_id = orders.id
AND notifications.user_id = ?
AND notifications.state = 0
WHERE `orders`.`deleted_at` IS NULL
GROUP BY orders.id