Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- How-to multiple select
February 19, 2006, 7:47 pm
rate this thread
I have a little problem.
I'm studying a blog program.
Given two tables : post and comment, i would like to retreve the number
of comments for each post.
In postgres the following is doable :
select id, title, body, (select count(*) from comment where post_id =
post.id) as total_comment from post
How-to do the same thing with MySQL?
If you have any idea.
Re: How-to multiple select
Basic usage of a "derived table or view" in a JOIN operation.
from post a,
(select id,count(*) as cnt from comment group by id ) b
where a.id = b.id ;
Donations welcomed. Http://www.firstdbasource.com/donations.html
- » Americanas.com SALDO de TVs Com at 80% de Desconto (29798)
- — Newest thread in » MySQL Database Forum