MySql ¸ñʽ»¯Ê±¼äº¯Êý
ÕâÀïÊÇÒ»¸öʹÓÃÈÕÆÚº¯ÊýµÄÀý×Ó¡£ÏÂÃæµÄ²éѯѡÔñÁËËùÓмǼ£¬Æädate_colµÄÖµÊÇÔÚ×îºó30ÌìÒÔÄÚ£º
mysql> SELECT something from table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
DAYOFWEEK(date)
·µ»ØÈÕÆÚdateµÄÐÇÆÚË÷Òý(1=ÐÇÆÚÌ죬2=ÐÇÆÚÒ», ……7=ÐÇÆÚÁù)¡£ÕâЩË÷ÒýÖµ¶ÔÓ¦ÓÚODBC±ê×¼¡£
mysql> select DAYOFWEEK('1998-02-03');
-> 3
WEEKDAY(date)
·µ»ØdateµÄÐÇÆÚË÷Òý(0=ÐÇÆÚÒ»£¬1=ÐÇÆÚ¶þ, ……6= ÐÇÆÚÌì)¡£
mysql> select WEEKDAY('1997-10-04 22:23:00');
-> 5
mysql> select WEEKDAY('1997-11-05');
-> 2
DAYOFMONTH(date)
·µ»ØdateµÄÔ·ÝÖÐÈÕÆÚ£¬ÔÚ1µ½31·¶Î§ÄÚ¡£
mysql> select DAYOFMONTH('1998-02-03');
-> 3
DAYOFYEAR(date)
·µ»ØdateÔÚÒ»ÄêÖеÄÈÕÊý, ÔÚ1µ½366·¶Î§ÄÚ¡£
mysql> select DAYOFYEAR('1998-02-03');
-> 34
MONTH(date)
·µ»ØdateµÄÔ·ݣ¬·¶Î§1µ½12¡£
mysql> select MONTH('1998-02-03');
-> 2
DAYNAME(date)
·µ»ØdateµÄÐÇÆÚÃû×Ö¡£
mysql> select DAYNAME("1998-02-05");
-> 'Thursday'
MONTHNAME(date)
·µ»ØdateµÄÔ·ÝÃû×Ö¡£
mysql> select MONTHNAME("1998-02-05");
-> 'February'
QUARTER(date)
·µ»ØdateÒ»ÄêÖеļ¾¶È£¬·¶Î§1µ½4¡£
mysql> select QUARTER('98-04-01');
-> 2
WEEK(date)
¡¡
WEEK(date,first)
¶ÔÓÚÐÇÆÚÌìÊÇÒ»ÖܵĵÚÒ»ÌìµÄµØ·½£¬ÓÐÒ»¸öµ¥¸ö²ÎÊý£¬·µ»ØdateµÄÖÜÊý£¬·¶Î§ÔÚ0µ½52¡£2¸ö²ÎÊýÐÎʽWEEK()ÔÊÐí
ÄãÖ¸¶¨ÐÇÆÚÊÇ·ñ¿ªÊ¼ÓÚÐÇÆÚÌì»òÐÇÆÚÒ»¡£Èç¹ûµÚ¶þ¸ö²ÎÊýÊÇ0£¬ÐÇÆÚ´ÓÐÇÆÚÌ쿪ʼ£¬Èç¹ûµÚ¶þ¸ö²ÎÊýÊÇ1£¬
´ÓÐÇÆÚÒ»¿ªÊ¼¡£
mysql> select WEEK('1998-02-20');
-> 7
mysql> select WEEK('1998-02-20',0);
-> 7
mysql> select WEEK('1998-02-20',1);
-> 8
YEAR(date)
·µ»ØdateµÄÄê·Ý£¬·¶Î§ÔÚ1000µ½9999¡£
mysql> select YEAR('98-02-03');
-> 1998
HOUR(time)
·µ»ØtimeµÄСʱ£¬·¶Î§ÊÇ0µ½23¡£
mysql> select HOUR('10:05:03');
-> 10
MINUTE(time)
·µ»ØtimeµÄ·ÖÖÓ£¬·¶Î§ÊÇ0µ½59¡£
mysql> select MINUTE('98-02-03 10:05:03');
-> 5
SECOND(time)
»ØÀ´timeµÄÃëÊý£¬·¶Î§ÊÇ0µ½59¡£
mysql> select SECOND('10:05:03');
-> 3
PERIOD_ADD(P,N)
Ïà¹ØÎĵµ£º
ÊÖ¶¯½¨±í£º
CREATE TABLE `excel` (
`id` int(11) DEFAULT NULL,
`name` varchar(50) DEFAULT NULL,
`passwd` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=gb2312; ×¢ÒâÊÇgb2312
È»ºóÔÚÁ¬½ÓÊý¾Ý¿âʱ¼ÓÉÏ:
useUnicode=true&characterEncoding=gb2312.
¾ÍokÀ²£¡ ......
1¡¢mysqlÊý¾Ý¿âÓÐÁ½ÖÖÇý¶¯£º
MySQL Connector/J Driver¡¢MMMysql driver¡£
2¡¢µ¼Èëµ¼³öÊý¾Ý¿âÃüÁ£¨binĿ¼Ï£©
µ¼³ö£ºmysqldump -u root -p bokele >c:/mysql.sql --default-character-set=gbk
µ¼È룺C:\mysql\bin\> mysql -u root -p
˵Ã÷£ºC:\mysql\bin\±íʾ½øÈëmysql³ÌÐò ......
ÕâÀï½éÉÜÒ»¸ö¼¯³É»·¾³ XAMPP¡£
XAMPP ÊÇÒ»¸öÒ×ÓÚ°²×°ÇÒ°üº¬ MySQL¡¢PHP ºÍ Perl µÄ Apache ·¢Ðа档XAMPP µÄÈ··Ç³£ÈÝÒ×°²×°ºÍʹÓãºÖ»ÐèÏÂÔØ£¬½âѹËõ£¬Æô¶¯¼´¿É¡£
ÏÂÔصØÖ·£º
http://www.apachefriends.org/zh_cn/xampp.html
µ½Ä¿Ç°ÎªÖ¹£¬XAMPP ¹²ÓÐÒÔÏÂËÄÖÖ°æ±¾£º
£¨1£©ÊÊÓÃÓÚ Linux µÄ XAMPP
£¨2£©ÊÊÓÃÓÚ Windows µ ......
java£¨jsp)ʹÓÃMySqlÊý¾Ý¿â,ÖÐÎÄÂÒÂëµÄÍêÕû½â¾ö·½°¸
mysqlÊÇÒ»¸öСÐ͵ĿªÔ´µÄÊý¾Ý¿â£¬ÓÃÀ´×ÔѧһЩ¼¼ÊõÊÇÊ®·Ö·½±ãµÄ¡£µ«Ê¹ÓÃmysql´æ´¢Êý¾Ý£¬Ò²»áÓöµ½Ò»Ð©·Ç³£¶ñÐĵÄÎÊÌ⣬È磺ÖÐÎÄÂÒÂëÎÊÌâ¡¢javaÇý¶¯³ÌÐòÎÞ·¨Ê¹ÓõÄÎÊÌ⣨ÒѾ½â¾ö£¬Ïê¼û£ºhttp://hi.baidu.com/lauo1988/blog/item/ff0da655bd3e2eceb745ae0b.html)¡£
......
<?php
/**
* ²Ù×÷mysql
µÄ»ù´¡À࣬ÆäËüÓëmysqlÓйصÄÀ඼¼Ì³ÐÓÚ´Ë»ùÀà
*
* ´ËclassÖеÄ$table¶¼ÊÇÒѾ°üº¬±íǰ׺µÄÍêÕû±íÃû
*
* ver 20090717
* ʹÓ÷¶Àý
* $db = new DB('localhost','root','password','database','utf8');
* $db->debug = true;
* $db->primaryKeys = array (
* 'table_1 ......