让我有三个表评论,附件,descendant_comments
代码:
SELECT comments.*, count(attachments.id)
FROM comments com
LEFT JOIN descendant_comments dc
ON dc.comments_id = com.id
LEFT OUTER JOIN attachments atch
ON (atch.comment_id = dc.child_comment_id OR atch.comment_id = com.id)
WHERE com.id = 77
我不想使用OR,因为它不是最佳方式。
有任何方法可以替换这行“OR atch.comment_id = com.id”