Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

mysqlÖÐʱ¼ä²éѯº¯Êý£¨°üÀ¨Ê±¼ä´Á£©

ÕâЩº¯Êý¶¼ÊÇMySQL×Ô´øµÄ£¬¿ÉÒÔÖ±½ÓʹÓÃÔÚPHPдµÄMySQL²éѯÓï¾äÖÐŶ
1-CURDATE()»òCURRENT_DATE()ºÍCURTIME()»òCURRENT_TIME()
ÕâÁ½¸öº¯ÊýÊDZȽϳ£Óõ½µÄ£¬¹ËÃû˼Ò壬µÚÒ»¸ö·µ»Øµ±Ç°ÈÕÆÚ£¬µÚ¶þ¸ö·µ»Øµ±Ç°Ê±¼ä
¿ÉÒÔÔÚMySQL¿Í»§¶Ë»òÕßPHPÓï¾äÀïд"SELECT CURDATE(),CURTIME()"²é¿´Ïà¹ØÐÅÏ¢.
»¹ÓÐÒ»¸öºÜÖØÒªµÄº¯ÊýNOW()£¬·µ»Øµ±Ç°ÈÕÆÚºÍʱ¼äÆäʵ¾ÍÊÇÉÏÃæÁ½¸öº¯Êý·µ»Ø½á¹ûµÄºÏ²¢¡£
2-DATE_ADDºÍDATE_SUB(date,INTERVAL int keyword)
ÕâÁ½¸öº¯ÊýºÜÖØÒª£¬·µ»ØÈÕÆÚdate¼ÓÉÏ»ò¼õÈ¥¸ñʽ»¯µÄʱ¼äINTERVAL int£¬Ïñ½ñÌìÓиöÅóÓÑÌáµ½ÈçºÎ²éѯһÖÜÖ®ÄÚµÄÊý¾Ý¾ÍÒªÓõ½Õâ¸öº¯Êý¡£
ÏÂÃæ½²Ò»ÏÂINTERVAL int keyword
ÏȾٸöÀý×Ó
PHP ´úÂë:
SELECT 

from tblname WHERE TIME
>
DATE_SUB
(
NOW
(),
INTERVAL 1 MONTH

Õâ¸öÓï¾äÖ´Ðк󷵻رíÖÐËùÓÐTIME×Ö¶ÎÖµ´Óµ±Ç°ÈÕÆÚÆðÒ»¸öÔÂÖ®ÄÚµÄÊý¾Ý
PHP ´úÂë:
SELECT 

from tblname WHERE TIME
>
DATE_SUB
(
NOW
(),
INTERVAL 
"1-1" 
YEAR_MONTH

Õâ¸öÓï¾ä·µ»Ø¾à½ñÒ»ÄêÁãÒ»¸öÔÂÖ®ÄÚµÄÊý¾Ý
Èç¹ûÓõ½DAY_SECOND²ÎÊý£¬Ç°ÃæµÄint¾Í±ØÐëÈç "1 12:23:34"ÕâÑùµÄ¸ñʽ
ÏÂÃæÊÇkeyword²ÎÊýÁбí
PHP ´úÂë:
MICROSECOND
SECOND
MINUTE
HOUR
DAY
WEEK 
MONTH 
QUARTER 
YEAR 
SECOND_MICROSECOND 
MINUTE_MICROSECOND 
MINUTE_SECOND     
HOUR_MICROSECOND     
HOUR_SECOND     
HOUR_MINUTE 
DAY_MICROSECOND     
DAY_SECOND     
DAY_MINUTE     
DAY_HOUR 
YEAR_MONTH 
ÆäÖÐQUARTERºÍWEEKÊÇMySQL5Ö®ºó²ÅÓеġ£
EXTRACT(keyword from date)-Õâ¸öº¯Êý´ÓÌṩµÄÈÕÆÚÖÐժȡ³öÏà¹ØÐÅÏ¢
PHP ´úÂë:
SELECT EXTRACT
(
DAY from NOW
()) 
¾Í·µ»Øµ±Ç°ÈÕÆÚµÄDAY£¬½ñÌìÊÇ16Èվͷµ»ØÊý×Ö16¡£
ÏÂÃæ½éÉܼ¸¸öÈÕÆÚʱ¼äº¯Êý
DAYOFWEEK(NOW())·µ»Øµ±Ç°ÈÕÆÚÊÇÕâÖܵĵÚÒ»Ì죬ÖÜÈÕÊǵÚÒ»Ì죬
DAYNAME(NOW())·µ»ØÐÇÆÚµÄÃû×Ö
DAYOFMONTH(NOW()) ·µ»Ø½ñÌìÊǼ¸ºÅ
DAYOFYEAR(NOW()) ·µ»Ø½ñÌìÊǽñÄêµÄµÚ¶àÉÙÌì
YEAR(NOW()) WEEK(NO


Ïà¹ØÎĵµ£º

java mysqlÁ¬½ÓÊý¾Ý¿â´úÂë

package com.lovo.cq.shopping10_1.common;
import java.sql.*;
public class DbUtil {
private PreparedStatement pstmt = null;
private Connection con = null;
public DbUtil() {
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://l ......

mysql°²×°µÄ¹ý³Ì

   ½ñÌìÖØÐÂ×°ÁËÒ»ÏÂmysqlÊý¾Ý¿â£¬½ØÖ¹µ½ÏÖÔÚÒѺÄʱ2£º30£¬ÓôÃÆ£¡£¡£¡£¡£¨ÎÒÔ­À´²»ÖªµÀ×°¹ý¶àÉÙ´Îmysql£©
   ËùÒÔÎÒ¾ö¶¨£¬°Ñ¹ØÓÚmysqlÊý¾Ý¿âµÄ³õʼ»¯²Ù×÷½éÉÜÒ»ÏÂ
£º
    1.°²×°mysqlÊý¾Ý¿â
       http://www.duote.com/tech/1/2430_1.html
  ......

MySQL ÄÚ´æÄ£ÐÍ hust ei

¶ÔÓÚÈκÎÒ»¸öÊý¾Ý¿â¹ÜÀíϵͳÀ´Ëµ£¬ÄÚ´æµÄ·ÖÅäʹÓþø¶Ô¿ÉÒÔËãµÄÉÏÊÇÆäºËÐÄÖ®Ò»ÁË£¬ËùÒԺܶàÏ£Íû¸üΪÉîÈëÁ˽âijÊý¾Ý¿â¹ÜÀíϵͳµÄÈË£¬¶¼»áÏ£ÍûÒ»¿ú¾¿¾¹£¬ÎÒÒ²²»ÀýÍâ¡£
´ÓÄÚ´æµÄʹÓ÷½Ê½MySQL Êý¾Ý¿âµÄÄÚ´æʹÓÃÖ÷Òª·ÖΪÒÔÏÂÁ½Àà
* Ï̶߳ÀÏíÄÚ´æ
* È«¾Ö¹²ÏíÄÚ´æ
½ñÌìÕâƪÎÄÕÂÔÝʱÏÈ·ÖÎö MySQL ÖÐÖ÷ÒªµÄ “Ï̶߳ÀÏíÄ ......

MySQL µÄ´¥·¢Æ÷¡¢´æ´¢¹ý³Ì¡¢º¯Êý¡¢ÊÓͼʵÑé

    ±¾ÊµÑéÍê³ÉÈçϽá¹û£º
    0. testÊý¾Ý¿â,userinfo Óû§ÐÅÏ¢±í ºÍ userinfolog Óû§ÐÅÏ¢ÈÕÖ¾±í
    1. ½¨Á¢Ò»¸öuserinfo±íÐÂÔö¼Ç¼ʱµÄ´¥·¢Æ÷,½«ÐÂÔöÈÕÖ¾¼ÓÈëµ½userinfolog
    2. ½¨Á¢Ò»¸öÏòuserinfo±íÐÂÔö¼Ç¼µÄ´æ´¢¹ý³Ì
    3. ¸ù¾ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ