mysql 多个结构相同的数据表,查询统计
$table = "union (select keyword,count(*) as result from v9_search_tongji_2 GROUP BY keyword ORDER BY result desc )";
$table .= "union (select keyword,count(*) as result from v9_search_tongji_3 GROUP BY keyword ORDER BY result desc )";
$table .= "union (select keyword,count(*) as result from v9_search_tongji_4 GROUP BY keyword ORDER BY result desc )";
$sql = " select keyword,sum(result) as u from ((select keyword,count(*) as result from v9_search_tongji GROUP BY keyword ORDER BY result desc ) ".$table.") as mmm group by mmm.keyword order by sum(result) desc limit 10";
+-------------+---------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------+----------------+
| id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| keyword | varchar(255) | NO | | NULL | |
| search_time | int(10) unsigned | NO | | NULL | |
| search_ip | varchar(255) | NO | | NULL | |
| isresult | tinyint(3) unsigned | NO | | NULL | |
| gp | tinyint(1) unsigned | NO | | 0 | |
+-------------+---------------------+------+-----+---------+----------------+
网站每查询一次,执行了一次入库,统计所有查询中查询次数最多的词