日期:2014-05-16  浏览次数:20735 次

请教,删记录
CREATE TABLE `wsz` (
  `name` char(2) NOT NULL,
  `money` int(11) NOT NULL,
  `time` date NOT NULL,
  KEY `name` (`name`,`money`,`time`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

#
# 导出表中的数据 `wsz`
#

INSERT INTO `wsz` (`name`, `money`, `time`) VALUES 
('a', 10, '2011-06-01'),
('a', 0, '2011-06-01'),
('a', 10, '2011-06-01'),
('a', 0, '2011-06-01'),
('b', 6, '2011-06-01'),
('b', 0, '2011-06-01'),
('b', 6, '2011-06-01'),
('b', 0, '2011-06-01'),


--------------
只删2011-06-01的重复的记录,

最后结果要:

a 10 2011-06-01
a 0 2011-06-01
b 6 2011-06-01
b 0 2011-06-01

------解决方案--------------------
creae table tb_temp select name, money, time from tb group by name,money,time


drop tabl tb;

alter table tb_temp rename tb;
------解决方案--------------------
select distinct `name`, `money`, `time` from `wsz`
------解决方案--------------------
探讨
creae table tb_temp select name, money, time from tb group by name,money,time


drop tabl tb;

alter table tb_temp rename tb;