Mysql 选择表的所有列,但行应按列中的唯一项或disticnt项进行筛选

Mysql 选择表的所有列,但行应按列中的唯一项或disticnt项进行筛选,mysql,Mysql,-- --正在转储表历史记录的数据 我想要一个查询,该查询应根据cid但唯一/不同的时间给出以下输出 打印唯一/独特的值 INSERT INTO `history` (`cid`, `pid`, `TIME`, `price`) VALUES (3, 1, '2014-11-12 17:39:14', '71500.0000'), (3, 3, '2014-11-12 17:39:14', '22500.0000'), (3, 1, '2014-11-12 17:40:36', '71500.0

--

--正在转储表
历史记录的数据
我想要一个查询,该查询应根据cid但唯一/不同的时间给出以下输出

打印唯一/独特的值

INSERT INTO `history` (`cid`, `pid`, `TIME`, `price`) VALUES
(3, 1, '2014-11-12 17:39:14', '71500.0000'),
(3, 3, '2014-11-12 17:39:14', '22500.0000'),
(3, 1, '2014-11-12 17:40:36', '71500.0000'),
(3, 1, '2014-11-12 17:52:36', '71500.0000'),
(3, 3, '2014-11-12 19:09:23', '22500.0000'),
(3, 5, '2014-11-12 19:09:23', '29000.0000'),
(3, 9, '2014-11-12 19:09:23', '29000.0000');

如果您尝试使用一个简单的子查询,如

  (3, '2014-11-12 17:39:14')
  (3, '2014-11-12 17:40:36')
  (3, '2014-11-12 17:52:36')
  (3, '2014-11-12 19:09:23')
  (3, '2014-11-12 19:09:23')
  (3, '2014-11-12 17:39:14')
  (3, '2014-11-12 17:40:36')
  (3, '2014-11-12 17:52:36')
  (3, '2014-11-12 19:09:23')
  (3, '2014-11-12 19:09:23')
select * from history where `time` in (select distinct `time` from history);