真的骄傲梦想家园
专业源于兴趣和努力
 1 SELECT c.*, sum(t.num) as num, b.num as total FROM np_wenjuan_choice as c
 2 left join (
 3 select content, count(id) as num
 4 from np_wenjuan_answer as a
 5 where question_id = 8
 6 group by content
 7 ) as t on t.content like concat('%',c.index,'%')
 8 left join (
 9 select question_id, count(id) as num 
10 from np_wenjuan_answer
11 where question_id = 8
12 group by question_id
13 ) as b on b.question_id = c.question_id
14 where c.question_id = 8
15 group by title
16 order by c.index

 

posted on 2012-07-07 14:40  真的骄傲  阅读(309)  评论(0编辑  收藏  举报