select count(*) as data_count from
media m, media_categorise c, media_group g, media_tag t, tag, user u
where
m.create_user = u.user_id and m.categorise_id = c.categorise_id and c.group_id = g.group_id and m.media_id = t.media_id and t.tag_id = tag.tag_id and
tag.tag_key = 'การจัดการ'
and (m.is_publish = 1 or m.create_user = 0) and m.is_drop = 0
group by
m.media_id, m.media_topic, m.media_text, m.media_file, m.media_ext, m.score_count, m.score_avg, m.is_publish, m.create_time,
g.group_name,
c.categorise_id,
u.user_name