List:General Discussion« Previous MessageNext Message »
From:Torkil Johnsen Date:April 12 2002 2:39pm
Subject:A small SQL query problem
View as plain text  
A small SQL query problem concerning articles and article_comments :) You
experts will have no problem with this :)


In brief:
---------
I have no problems displaying the title, date, author, summary of the
articles or anything. Its just doing an sql query that gets my 3 latest
articles AND counts how many comments each article has, and doing it in ONE
query instead of two separate ones... :(


In *not* brief:
---------------
I have 2 tables.
One contains articles, basically like this:
-------------------------------------------------------
| id  |  title  |  summary | text  |  date  | author  |
-------------------------------------------------------

The other containts comments to the articles, basically looks like this:

-----------------------------------
| id | article_id | text | author |
-----------------------------------

Now, on my main page I want to display the first 3 articles like this:

TITLETITLETITLETITLETITLE (date)
written by AUTHOR

SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY
SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY
SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY SUMMARY
>> Read the whole story (comments: ##)

My actual problem is how to get the number of comments (##)!

I have no problems displaying the title, date, author, summary or anything.
Its just doing an sql query that counts how many comments the article has,
and doing it in ONE query instead of two separate ones... :(

Thread
A small SQL query problemTorkil Johnsen12 Apr
  • RE: A small SQL query problemRoger Baklund12 Apr
Re: A small SQL query problemTorkil Johnsen12 Apr
  • Re: A small SQL query problemJohn Klein12 Apr
  • RE: A small SQL query problemRoger Baklund12 Apr