select p.pid,p.p_title,p.p_content,ca.cid c_id,ca.c_name,
select tag1+','tag2' as tags
from
(
(
select
max( case tag when '标签1' then tag else 'null' end) as tag1,
max(case tag when '标签2' then tag else 'null' end) as tag2
from posttags
group by pid
) t1
) t2
,
count(*) as commentsCount
from posts p,comments com,category ca
where p.pid=com.pid
and com.cid=ca.cid
group by p.pid,p.p_title,p.p_content,ca.cid,ca.c_name;
没有环境测试,你亲自测试一下吧