查询条件的格式

时间:2010-10-11 08:15:18

标签: mysql

以下代码是查询的一部分。我似乎对AND ON C2.loginid = S2.loginid代码的部分格式有误。我应该使用什么格式?

提前致谢,

约翰

LEFT JOIN (
    SELECT S2.loginid, COUNT(1) AS total 
    FROM submission S2
    INNER JOIN comment C2
    ON C2.submissionid = S2.submissionid
    AND ON C2.loginid = S2.loginid
    GROUP BY S2.loginid
) scs ON scs.loginid = l.loginid

1 个答案:

答案 0 :(得分:1)

AND ON C2.loginid = S2.loginid ==>在ON

之后删除AND
LEFT JOIN (
    SELECT S2.loginid, COUNT(1) AS total 
    FROM submission S2
    INNER JOIN comment C2
    ON C2.submissionid = S2.submissionid
      AND C2.loginid = S2.loginid
    GROUP BY S2.loginid
) scs ON scs.loginid = l.loginid