2015-04-03

mysql 复制表和时间相关语句

1.mysql 复制表的结构

create table table_name select * from original_table_name where 1=2;

复制表的结构和内容
create table table_name select * from original_table_name where 1=1;

三个月前的记录
1.select * from table where time> date_add(now(),interval-3 month) order by id

两个月的记录
2.select * from table where to_days(now())-to_days(time) > 60 order by id

时间戳
where unix_timestamp(addtime) >