0

我的论坛有两个表来存储主题(posts 和 forums_archive_posts)

$this->DB->build( array(
                                    'select'    => "HOUR( FROM_UNIXTIME( post_date ) ) as hour, COUNT(*) AS postCount",
                                    'from'      => 'posts',
                                    'where'     => "new_topic=0 AND author_id=" . $member['member_id'],
                                    'group'     => 'HOUR( FROM_UNIXTIME( post_date ) )',
                        )       );

此查询仅适用于第一个表(帖子),我需要一个也适用于“forum_archive_posts”的查询

表结构(forum_archive_posts=posts):

archive_author_id = author_id

archive_content_date = post_date

4

1 回答 1

0

不知道你是如何以这种格式做的,但类似

Select postHour, sum(postcount) as postCount From
(
  select Hour ...  as PostHour
  From 
  Posts...
  Union
  Select Hour ...
  From
  ForumArchivePosts ...
) dummyTableName
Group by PostHour

应该做的工作。从两个表中计算 bny hoiurs,然后将它们加在一起。

于 2012-12-10T18:26:17.100 回答