Adding a third table to a Join
- by John
Hello,
This query works fine:
$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";
Would this work if I wanted to join a third MySQL table (called "comment") to it?
$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";
Thanks in advance,
John