我有一张桌子:
CREATE TABLE IF NOT EXISTS `ccu_log` (
`id` int(15) NOT NULL AUTO_INCREMENT,
`ccu` int(10) DEFAULT NULL,
`time` time DEFAULT NULL,
`date` date DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5626 ;
--
-- Dumping data for table `ccu_log`
--
INSERT INTO `ccu_log` (`id`, `ccu`, `time`, `date`) VALUES
(1, 0, '22:27:30', '2015-01-08'),
(2, 0, '22:29:01', '2015-01-08'),
(3, 0, '22:30:31', '2015-01-08'),
(4, 0, '22:32:01', '2015-01-08'),
(5, 3, '22:33:31', '2015-01-08'),
(6, 0, '22:35:01', '2015-01-08'),
(7, 4, '22:36:31', '2015-01-08'),
(8, 8, '22:38:01', '2015-01-09'),
(9, 5, '22:39:31', '2015-01-09'),
(10, 1, '22:41:01', '2015-01-09');
当我想使用mysql查询选择数据时:
SELECT *
FROM `ccu_log`
WHERE UNIX_TIMESTAMP("date") = UNIX_TIMESTAMP('09-01-2015')
它显示了我表中的所有行。如果我用户查询:
SELECT * FROM `ccu_log` where UNIX_TIMESTAMP(date) = UNIX_TIMESTAMP('09-01-2015')
它不会返回预期的结果。
有什么建议么?
最佳答案
请这样尝试
SELECT * FROM `ccu_log` where DATE_FORMAT(date,"%d-%m-%Y") = '09-01-2015';
关于php - 我要选择数据,但不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29273037/