此查詢工作正常:添加第三個表的加入
$sqlStr = "SELECT s.loginid, s.title, s.url, s.displayurl, l.username
FROM submission AS s,
login AS l
WHERE s.loginid = l.loginid
ORDER BY s.datesubmitted DESC
LIMIT 10";
將這項工作,如果我想加入第三MySQL表(稱爲「評論」)呢?
$sqlStr = "SELECT s.loginid, s.submissionid s.title, s.url, s.displayurl, l.username, count(c.comment) countComments
FROM submission AS s,
login AS l,
comment AS c,
WHERE s.loginid = l.loginid
AND s.submissionid = c.submissionid
ORDER BY s.datesubmitted DESC
LIMIT 10";
由於提前,
約翰