我正在阅读这篇文章,并试图理解这个 SQL 语句,但我对 SQL 还是有些陌生。
我不确定评论和 c 指的是什么。
我认为其中一个是表名,但我不确定另一个。此外,显然其中有一个子查询,我没有任何经验:
SELECT c.id, c.user_id, c.body, c.deep, c.lineage, c.parent_id,
(SELECT COUNT(*)
FROM comment
WHERE comment.lineage LIKE (CONCAT(c.lineage,'%'))
AND comment.lineage != c.lineage) AS replies
FROM comment as c
ORDER BY c.lineage