I have a database table
my code inserts a row here everytime user solves a question.
CREATE TABLE `u_s_q` (
`ID` int(8) NOT NULL auto_increment,
`userid` int(6) NOT NULL,
`questionid` int(6) NOT NULL,
`time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `u_s_q`
--
INSERT INTO `u_s_q` VALUES (1, 1, 2, '2011-11-26 14:02:14');
INSERT INTO `u_s_q` VALUES (2, 1, 5, '2011-11-26 14:24:32');
like this.
I am trying to see the question id’s that user with the id = “1” solved in the month of november.
I don’t know how to write that SQL statement
How do I write that?
Use
MONTH(time)to return the month number, and query for 11 (November)Alternatively, use
MONTHNAME()to get the actual word “November”, or whatever it would be called in your locale