Link to home
Create AccountLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

select count and information from table mysql

Hi all

A quick (and hopefully easy) question.

We have two tables, one for storing atricles, and another for storing comments assciated  with the article.

Table Article
ID, picture, title, text

Table comment
ID, articleID, comment

Now I want to be able to select the following;

article.title, article.text, article.picture, Count(select row countof comments associated with article) FROM article;

ASKER CERTIFIED SOLUTION
Avatar of wuyinzhi
wuyinzhi
Flag of Indonesia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Aaron Tomosky
Select article.title, article.text, article.picture, (select count(*) from comment where articleid = article.id ) as commentcount FROM article;