Join with three tables

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-03-24T00:09:44Z Indexed on 2010/03/24 0:13 UTC
Read the original article Hit count: 589

Filed under:


For the join query below, I would like to pull some data from a third MySQL table called "comment." Each s.title has a corresponding s.submissionid. The field "submissionid" is also the in the table "comment."

For each "submissionid" in the table "comment," I would like to count a field called "commentid."

How can I do this?

Thanks in advance,


$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";

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql