delete from barp where cast(dat as datetime)<='2013-01-01'
建议,删除之前最好先备份一下,或者
select from barp where cast(dat as datetime)<='2013-01-01'
执行一下查询,看看是不是想要删除的数据
---------补充--------
先执行下这个
select from barp where cast(dat as datetime)<='2013-01-01'
确认一下,是不是查询出来的结果是要删除的数据,确认后
执行
delete from barp where cast(dat as datetime)<='2013-01-01'
你啥都不用改,我是按照你表名和字段名写的
额,你要是保留2013年1月1号的数据,就把<=改成<
CREATE TABLE `abc` (
`countNumber` int(11) NOT NULL default '0',
`cdate` datetime NOT NULL default '2007-01-01 00:00:00',
KEY `a` (`countNumber`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---------------------------------------------------------------------
insert into abc values (11,'2012-03-19');
insert into abc values (12,'2012-03-18');
insert into abc values (13,'2012-03-17');
insert into abc values (14,'2012-03-16');
insert into abc values (15,'2012-03-15');
insert into abc values (16,'2012-03-14');
insert into abc values (17,'2012-03-13');
insert into abc values (18,'2012-03-12');
insert into abc values (22,'2012-03-11');
insert into abc values (32,'2012-03-10');
insert into abc values (1,'2012-03-09');
测试数据
-----------------------------------------------------------------------
select (case when weekday(cdate)=6 then 'xingqi7' when weekday(cdate)=0 then 'xingqi1'when weekday(cdate)=1 then 'xingqi2'when weekday(cdate)=2 then 'xingqi3'when weekday(cdate)=3 then 'xingqi4'when weekday(cdate)=4 then 'xingqi5'when weekday(cdate)=5 then 'xingqi6' end) as weekname, countnumber, avg(countnumber) from abc where week(now())-week(cdate)=1 and date_format(cdate,'%H:%i:%s')='00:00:00' group by countnumber union select 'allcount', sum(countnumber),sum(countnumber)/count() from abc where week(now())-week(cdate)=1 and date_format(cdate,'%H:%i:%s')='00:00:00' ;
注意,这边我是以周日为每周的开始
以上就是关于如何删除sql2000数据库中barp表中2013-1-1之前的数据全部的内容,包括:如何删除sql2000数据库中barp表中2013-1-1之前的数据、急求!mysql 数据库 datetime问题、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)