Re: [PHP] Super SQL problem! Please advise!

2001-02-09 Thread Sandeep Hundal
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

Re: [PHP] Super SQL problem! Please advise!

2001-02-08 Thread Graham Reeves
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

Re: [PHP] Super SQL problem! Please advise!

2001-02-08 Thread Steve Werby
"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

Re: [PHP] Super SQL problem! Please advise!

2001-02-08 Thread Sandeep Hundal
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,

Re: [PHP] Super SQL problem! Please advise!

2001-02-07 Thread Steve Werby
"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