±í CREATE TABLE `ch1` ( `id` int(10) unsigned zerofill NOT NULL AUTO_INCREMENT, `no` int(10) unsigned DEFAULT NULL, `dtime` datetime DEFAULT NULL, PRIMARY KEY (`id`) ) ²éѯÓï¾ä select sum(no) as number,dtime as date from ch1 group by month(dtime) Êý¾Ý´óÔ¼1000wÌõ¼Ç¼£¬ÐèÒª40Ã룬¸Ð¾õÌ«ÂýÁË£¬ÓÐʲô½â¾ö°ì·¨£¿ÐèÒªÔÚdtimeÉÏ´´½¨Ò»¸öË÷Òý¡£
create index idx_dtime on ch1(dtime); Èç¹ûÖ»ÊÇÕâÌõÓï¾äµÄ»°£¬ÔÚdtimeÉϽ¨Á¢Ë÷ÒýÊÔÊÔ Â¥Éϵķ½·¨ ·Ö×éÁÐÉϽ¨Ë÷Òý group by month(dtime)
Õâ¸ö½¨¸öË÷Òý¾ÍOKÁ˰¡ ͬÒâÖîλÒâ¼û£¡ ½¨Á¢Ë÷ÒýÖ®ºó´óÔ¼ÐèÒª¶àÉÙʱ¼ä£¿ Ë÷Òý²»ÆðÈκÎ×óÓÒ ÕâÊÇ·ÖÎöÖ´ÐÐÓï¾äµÄʱºòµÄ½á¹û Extra£º Using temporary; Using filesort Ë÷Òý²»ÆðÈκÎ×óÓÒ ÕâÊÇ·ÖÎöÖ´ÐÐÓï¾äµÄʱºòµÄ½á¹û Extra£º Using temporary; Using filesort select sum(
String SQL="insert into ѧÉúÐÅÏ¢±í values(StudentNumber,StudentName,StudentAge)";ÆäÖÐStudentNumber,StudentName,StudentAge¶¼ÊDZäÁ¿¡£ÕâÑùд²»¶Ô¡¡µ½µ×¸Ãզд°¡