Thanks a lot for your help everyone!!! It worked!! Woohoo!! Not only
that, I learned about joins! :)
/sunny
--- Steve Werby <[EMAIL PROTECTED]> wrote: > "Sandeep Hundal"
<[EMAIL PROTECTED]> wrote:
> > thanks for the tip steve. i read up on left joins, and got this:
> > SELECT diary.id, diary.the
Sandeep try this
SELECT
d.id,
d.thedate,
d.topic,
d.entry,
count(c.id) AS comments
FROM
diary d left outer join comments c on (d.id = c.id)
WHERE
d.month='$month'
GROUP BY
c.id
ORDER BY
d.id DESC "
Cheers
_
Graham Reeves
Consultant
PQ Africa - Q Data C
"Sandeep Hundal" <[EMAIL PROTECTED]> wrote:
> thanks for the tip steve. i read up on left joins, and got this:
> SELECT diary.id, diary.thedate, diary.topic, diary.entry
> FROM diary
> LEFT JOIN comments
> ON diary.id = comments.id;
>
> but it only joins the two tables.
Right. It took care of yo
thanks for the tip steve. i read up on left joins, and got this:
SELECT diary.id, diary.thedate, diary.topic, diary.entry
FROM diary
LEFT JOIN comments
ON diary.id = comments.id;
but it only joins the two tables. What I need is only 1 column from
the second table, counted. Something like this,
"Sandeep Hundal" <[EMAIL PROTECTED]> wrote:
> SELECT diary.id, diary.thedate, diary.topic, diary.entry,
> count(comments.id) AS comments FROM diary, comments WHERE
> diary.month='$month' AND diary.id = comments.id GROUP BY comments.id
> ORDER BY diary.id DESC "
>
> Basically what I've done is made
5 matches
Mail list logo