CREATE TABLE IF NOT EXISTS `history` (
`bill_no` int(11) NOT NULL,
`cid` int(11) NOT NULL,
`pid` int(11) NOT NULL,
`TIME` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
`price` decimal(65,4) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-
history
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');
我希望在cid的基础上给出以下输出但是独特/不同的TIME
打印独特/不确定的价值
(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')
答案 0 :(得分:0)
如果尝试使用像
这样的简单子查询,该怎么办?select * from history where `time` in (select distinct `time` from history);