【发布时间】:2011-07-14 06:48:03
【问题描述】:
我正在阅读this article,我正在尝试理解这个 SQL 语句,但我对 SQL 还是有些陌生。
我不确定 comment 和 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
【问题讨论】:
-
你可能也对这个问题感兴趣When to use SQL Table Alias