现在是用create table syn_count as select srcip,dstip,dstport,count(*) from syn
group by srcip,dstip,dstport;
这个语句 生成新表,想把表名定义为"date"_syn_count  
date为当前日期
然后对"date"_syn_count这个表进行处理,挑出count(*)字段中大于1000的,输出到新表"date"_syn_count_high
大于100小于1000的 输出到新表"date"_syn_count_middle
小于100的输出到新表"date"_syn_count_low

解决方案 »

  1.   

    SET @asql=CONCAT('create table `',CURDATE(),'_syn_count` as select srcip,dstip,dstport,count(*) from syn group by srcip,dstip,dstport');
    PREPARE stml FROM @asql;
    EXECUTE stml;
      

  2.   

    sql 不知道,shell mysql  -e "use test; create table `date +%Y%m%d`_my_table (a int)";
      

  3.   

    建议在你的脚本语言中实现,使用二楼这种方式。从数据库设计角度,则应该考虑一下,为什么要每天创建一个表,尽可能不要在运行过程中仍然需要执行DDL语句。
      

  4.   

    因为要对每天生成的数据进行处理并归档,所以我想是每天建一个表
    这样以后查的话  也好查谢谢几位指点,我去看下用bash实现吧不过取范围值的是不是还是用mysql好点,听说有现成的函数?
      

  5.   

    select * from syn_count
    where count(*) > '1000';1111 - Invalid use of group function
    这么写怎么报错呢
      

  6.   

    示例:
    select srcip,dstip,dstport,count(*) from syn
    group by srcip,dstip,dstport having count(*) > 1000;