½ñÌì¸ø´ó¼Ò½éÉÜÁùÌõ±È½ÏÓÐÓõÄMySQLµÄSQLÓï¾ä£¬¿ÉÄܺܶàÈ˶¼Í¨¹ýPHPÀ´ÊµÏÖÕâЩ¹¦ÄÜ¡£
1. ¼ÆËãÄêÊý
ÄãÏëͨ¹ýÉúÈÕÀ´¼ÆËãÕâ¸öÈËÓм¸ËêÁË¡£
SELECT DATE_FORMAT(FROM_DAYS(TO_DAYS(now()) - TO_DAYS(@dateofbirth)), '%Y' ) + 0; |
2. Á½¸öʱ¼äµÄ²î È¡µÃÁ½¸ö datetime ÖµµÄ²î¡£
¼ÙÉè dt1 ºÍ dt2 ÊÇ datetime ÀàÐÍ£¬Æä¸ñʽΪ ¡®yyyy-mm-dd hh:mm:ss¡¯£¬ÄÇôËüÃÇÖ®¼äËù²îµÄÃëÊýΪ£º
UNIX_TIMESTAMP( dt2 ) - UNIX_TIMESTAMP( dt1 ) |
¡¡¡¡
³ýÒÔ60¾ÍÊÇËù²îµÄ·ÖÖÓÊý£¬³ýÒÔ3600¾ÍÊÇËù²îµÄСʱÊý£¬ÔÙ³ýÒÔ24¾ÍÊÇËù²îµÄÌìÊý¡£
3. ÏÔʾijһÁгöÏÖ¹ýN´ÎµÄÖµ
SELECT id FROM tbl GROUP BY id HAVING COUNT (*) = N; |
¡¡¡¡
4. ¼ÆËãÁ½¸öÈÕ×Ó¼äµÄ¹¤×÷ÈÕ Ëùν¹¤×÷ÈÕ¾ÍÊdzý³öÖÜÁùÖÜÈպͽڼÙÈÕ¡£
SELECT COUNT (*) FROM calendar WHERE d BETWEEN Start AND Stop AND DAYOFWEEK(d) NOT IN (1,7) AND holiday=0; |
¡¡¡¡
5. ²éÕÒ±íÖеÄÖ÷¼ü
SELECT k.column_name FROM information_schema.table_constraints t |
¡¡¡¡¡¡¡¡ JOIN information_schema.key_column_usage k USING (constraint_name,table_schema,table_name) |
¡¡¡¡¡¡¡¡¡¡¡¡ WHERE t.constraint_type= 'PRIMARY KEY' AND t.table_schema= 'db' AND t.table_name=tbl' |
¡¡¡¡
6. ²é¿´ÄãµÄÊý¿âÓжà´ó
SELECT |
¡¡¡¡table_schema AS 'Db Name' , |
¡¡¡¡Round( Sum ( data_length + index_length ) / 1024 / 1024, 3 ) AS 'Db Size (MB)' , |
¡¡¡¡Round( Sum ( data_free ) / 1024 / 1024, 3 ) AS 'Free Space (MB)' |
FROM information_schema.tables GROUP BY table_schema ; |
¡¡¡¡
Ï£Íû¶ÔÄãÓаïÖú¡£
ÍƼöÐÅÏ¢
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- php³£ÓÃÕýÔò±í´ïʽ
- phpÐÔÄܼà²âÄ£¿éXHProf
- ÈÃCI¿ò¼ÜÖ§³Öservice²ã
- ʹÓÃPHPÉú³É´øLOGOµÄ¸öÐÔ»¯¶þάÂëͼÏñ
- ¹ØÓÚCodeIgniterÄã¿ÉÄܲ»ÖªµÀµÄ5¸ö֪ʶµã
- Memcache ºÁÃ뼶³¬Ê±¼°ÆäËû³£¼ûÎÊÌâ»ã×Ü
- [PHP±Ê¼Ç]PHPQueryÒ»¸ö´¦ÀíDOMµÄÀûÆ÷
ÈÈÃÅÐÅÏ¢
- nohup: redirecting stderr to stdou....
- ʹÓÃlog_formatΪNginx·þÎñÆ÷ÉèÖøüÏêϸµÄÈÕÖ¾¸ñʽ
- jquery easyUI--dataGrid-Json
- [Ô´´]·ÂGoogle Reader¡¢ÐÂÀË΢²©¡¢ÌÚѶ΢²©µ....
- ÀûÓÃKeepalived+mysql¹¹½¨¸ß¿ÉÓÃMySQLË«Ö÷×Ô¶....
- Nginx+keepalivedʵÏÖ¸ºÔؾùºâºÍË«»úÈȱ¸¸ß¿ÉÓÃ
- jqueryʵÏÖÒ³Ãæ¼ÓÔؽø¶ÈÌõ
- Rolling cURL: PHP²¢·¢×î¼Ñʵ¼ù
- codeigniter ·ÓÉÖÕ¼«ÓÅ»¯(url rewrite)
- linuxÏÂÉèÖÃsshÎÞÃÜÂëµÇ¼
×î½ü¸üÐÂ
- PHP»ñÈ¡Óû§µÄÕæʵIP£¬²¢ÅжÏÊÇ·ñÄÚÍøIP
- PHP ´íÎóÈÕÖ¾ error_log
- ÀûÓÃbigpipe»úÖÆʵÏÖÒ³ÃæÄ£¿éµÄÒì²½äÖȾ chunked¼¼Êõ
- php¿ØÖÆÎļþÏÂÔØËÙ¶È
- js + php ¶ÁÈ¡¡¢²¥·ÅÊÓƵÁ÷ ¼æÈÝfirefox£¬c....
- ¡¾ÊÓƵ²¥·Å¡¿JplayerÊÓƵ²¥·ÅÆ÷µÄʹÓÃ
- UNICODE Óë UTF-8 µÄ¹Øϵ
- memcacheÄÚ´æÔÀí
- Memcache¼¼Êõ·ÖÏí£º½éÉÜ¡¢Ê¹Óᢴ洢¡¢Ëã·¨¡¢ÓÅ»¯....
- phpʹÓÃmb_detect_encoding¼ì²â×Ö·û´®±àÂë
ÆÀÂÛ