我需要将统计信息表hits
中的信息插入到info
表中,其中包含来自hits
表
我有这个查询插入哪个工作正常并插入基于ip的唯一计数
INSERT INTO `stats`.`info`
(`id`,`rate`,`date`,`count_date`,`count_country`,`country`)
(
SELECT `id`, SUM(s.`rate`) AS `rate`, s.`date` AS `date`, COUNT(s.`ip`) AS `count_date`
FROM(
SELECT
`id`,`ip`,`rate`,`timestamp`,`date`
FROM `stats`.`hits
GROUP BY `date`,`ip`
) s
WHERE (`timestamp` >= '$today' AND `timestamp` < '$nextday')
GROUP BY `id`
)
列count_country
和country
需要从同一id
的其他查询中插入
获取count_country
和country
的查询是
SELECT COUNT(s.`ip`) AS `count_country`, `country`
FROM(
SELECT
`ip`,`country`
FROM `stats`.`hits
GROUP BY `country`,`ip`
) s
GROUP BY `country`
是否可以将此查询添加到INSERT查询中,以便为同一id
由于