mysqlº¯Êý
ÓÃÔÚSELECTºÍWHERE×Ó¾äµÄº¯Êý
--------------------------------------------------------------
1 ·Ö×麯Êý
( ... ) À¨ºÅ¡£Ê¹ÓÃËüÃÇÀ´Ç¿ÖÆÔÚÒ»¸ö±í´ïʽµÄ¼ÆËã˳Ðò¡£
--------------------------------------------------------------
2 ³£ÓõÄËãÊõÔËËã
£¨+ - * /£©
Ò»°ãµÄËãÊõ²Ù×÷·ûÊÇ¿ÉÓõġ£×¢ÒâÔÚ-¡¢+ºÍ*Çé¿öÏ£¬Èç¹ûÁ½¸ö²ÎÊýÊÇÕûÊý£¬½á¹ûÓÃBIGINT£¨64룩¾«¶È¼ÆË㣡
--------------------------------------------------------------
3 λº¯Êý
| λ»ò
& λÓë
<< ×óÒÆλһ¸ö³¤(BIGINT)Êý×Ö
>> ÓÒÒÆλһ¸ö³¤(BIGINT)Êý×Ö
~ µßµ¹ËùÓеÄλ
BIT_COUNT(N) ·µ»ØÔÚ²ÎÊýNÉ趨µÄλµÄÊýÁ¿
--------------------------------------------------------------
4 Âß¼ÔËËã
ËùÓеÄÂß¼º¯Êý·µ»Ø1£¨TRUE£©»ò0£¨FALSE£©
NOT (!)
Âß¼·Ç¡£Èç¹û²ÎÊýÊÇ0£¬·µ»Ø1£¬·ñÔò·µ»Ø0¡£ÀýÍ⣺ NOT NULL·µ»ØNULL
OR (||)
Âß¼»ò¡£Èç¹ûÈκÎÒ»¸ö²ÎÊý²»ÊÇ0²¢ÇÒ²»NULL£¬·µ»Ø1¡£
AND (&&)
Âß¼Óë¡£Èç¹ûÈκÎÒ»¸ö²ÎÊýÊÇ0»òNULL£¬·µ»Ø0£¬·ñÔò·µ»Ø1¡£
--------------------------------------------------------------
5 ±È½ÏÔËËã·û
±È½Ï²Ù×÷µÃ³öÖµ1£¨TRUE£©¡¢0£¨FALSE£©»òNULLµÈ½á¹û¡£ÕâЩº¯Êý¹¤×÷ÔËÓÃÔÚÊý×ÖºÍ×Ö·û´®ÉÏ¡£µ±ÐèҪʱ£¬×Ö·û´®×Ô¶¯µØ±»±ä»»µ½Êý×ÖÇÒÊý×Öµ½×Ö·û´®(ÈçÔÚPerl)¡£
expr
IN (value,...)
Èç¹ûexprÊÇÔÚIN±íÖеÄÈκÎÖµ£¬·µ»Ø1£¬·ñÔò·µ»Ø0¡£Èç¹ûËùÓеÄÖµÊdz£Êý£¬ÄÇôËùÓеÄÖµ¸ù¾ÝexprÀàÐͱ»¼ÆËãºÍÅÅÐò£¬È»ºóÏîÄ¿µÄËÑË÷ÊÇÓöþ½øÖƵÄËÑ
Ë÷Íê³É¡£ÕâÒâζ×ÅÈç¹ûINÖµ±íÈ«²¿Óɳ£Êý×é³É£¬INÊǺܿìµÄ¡£Èç¹ûexprÊÇÒ»¸ö´óСдÃô¸ÐµÄ×Ö·û´®±í´ïʽ£¬×Ö·û´®±È½ÏÒÔ´óСдÃô¸Ð·½Ê½Ö´ÐС£
expr NOT IN (value,...) ÓëNOT (expr IN (value,...))Ïàͬ¡£
ISNULL(expr) Èç¹ûexprÊÇNULL£¬ISNULL()·µ»Ø1£¬·ñÔòËü·µ»Ø0¡£
COALESCE(list) »ØÀ´listÖеÚÒ»¸ö·ÇNULLµÄµ¥Ôª¡£
INTERVAL(N,N1,N2,N3,...) Èç¹ûN< N1£¬·µ»Ø0£¬Èç¹ûN<
N2£¬·µ»Ø1µÈµÈ¡£ËùÓеIJÎÊý±»µ±×÷ÕûÊý¡£ÎªÁ˺¯ÊýÄÜÕýÈ·µØ¹¤×÷£¬ËüÒªÇóN1<N2<N3<
...<Nn¡£ÕâÊÇÒòΪʹÓöþ½øÖÆËÑË÷(ºÜ¿ì)¡£
-----
Ïà¹ØÎĵµ£º
Ðí¶àÅóÓÑÔÚʹÓÃmysql½øÐÐÖÐÎÄÄ£ºý²éÕÒʱ(Èçselect * from mytable where mysqlname like "%ÖÐÎÄ%"),¾ÍÏóÎÒÏÖÔÚÒ»Ñù£¬ÕÒµ½²»Ó¦ÕÒµ½µÄÐÐ!
ÓÐһЩÅóÓÑÌá³öÁ˽â¾ö°ì·¨£¬´óÖÂÓÐÁ½ÖÖ£º
ÆäÒ»£¬¼Ó×Ö¶ÎÊôÐÔbinary(),
Æä¶þ,¸Ämy.cfgÆô¶¯²ÎÊýΪdefault-character-set =gbk(»ògb2312).
ÎÒ´ÓÎÊÌâµÄ¸ù±¾ÔÒò·ÖÎö£¬
ÆäÒ»£¬×Öĸ ......
ת×Ôhttp://amoeba.meidusa.com/wordpress/?p=24£¬Ò»¸öºÜºÃµÄ¹¤¾ß¡£¡£¡£¡£ÆÚ´ýÑо¿
ÐÞ¸´bugÁбí:
1¡¢ÐÞ¸´ÎÞ·¨½âÎöÅ׳öunknown statement£¨1.0.0ÐÂbug£©¡£½«ÎÞ·¨½âÎöµÃsqlĬÈÏÔÚdefaultPoolÖÐÖ´ÐÐ
2¡¢ÐÞ¸´union¹Ø¼ü×ÖÎÞ·¨½âÎöÎÊÌâ
3¡¢ÐÞ¸´º¯ÊýÇ°Ãæ! ÎÞ·¨½âÎöÎÊÌâ
4¡¢ÐÞ¸´order by ¡¢group by ºóÃæ´ø±í´ïʽµÃsql
ÏÂÔØµØ ......
THREAD_CACHE MySQLÀïÃæΪÁËÌá¸ß¿Í»§¶ËÇëÇó´´½¨Á¬½Ó¹ý³ÌµÄÐÔÄÜ,ÌṩÁËÒ»¸öÁ¬½Ó³ØÒ²¾ÍÊÇThread_Cache³Ø,½«¿ÕÏеÄÁ¬½ÓÏ̷߳ÅÔÚÁ¬½Ó³ØÖÐ,¶ø²»ÊÇÁ¢¼´Ïú»Ù.ÕâÑùµÄºÃ´¦¾ÍÊÇ,µ±ÓÖÓÐÒ»¸öеÄÇëÇóµÄʱºò,mysql²»»áÁ¢¼´È¥´´½¨Á¬½ÓÏß³Ì,¶øÊÇÏÈÈ¥Thread_CacheÖÐÈ¥²éÕÒ¿ÕÏеÄÁ¬½ÓÏß³Ì,Èç¹û´æÔÚÔòÖ±½ÓʹÓÃ,²»´æÔڲŴ´½¨ÐµÄÁ¬½ÓÏß³Ì. ÓÐ ......
Ò»¡¢MySQL »ñµÃµ±Ç°ÈÕÆÚʱ¼ä º¯Êý
1.1 »ñµÃµ±Ç°ÈÕÆÚ+ʱ¼ä£¨date + time£©º¯Êý£ºnow()
mysql> select now();
+---------------------+
| now() |
+---------------------+
| 2008-08-08 22:20:46 |
+---------------------+
³ýÁË now() º¯ÊýÄÜ»ñµÃµ±Ç°µÄÈÕÆÚʱ¼äÍ⣬MySQL Öл¹ÓÐÏÂÃæµÄº¯Êý£º ......
MySQLÎå¸ö²éѯÓÅ»¯·½·¨
ÊìϤSQLµÄÈ˶¼ÖªµÀ£¬Íê³Éͬһ¸öÈÎÎñ£¬SQL¿ÉÄÜÓжàÖÖд·¨£¬µ«²»Í¬Ð´·¨µÄ²éѯ
ÐÔÄÜ¿ÉÄÜ»áÓÐÌìÈÀÖ®±ð£¬±¾ÎÄÁоٳöÎå¸ö²éѯÓÅ»¯µÄ·½·¨
£¬µ±È»£¬ÓÅ»¯µÄ·½·¨»¹Óкܶࡣ¡¡¡¡
1¡¢ÓÅ»¯Êý¾ÝÀàÐÍ
MySQL
ÖÐÊý¾ÝÀàÐÍÓжàÖÖ£¬Èç¹ûÄãÊÇÒ»ÃûDBA£¬ÕýÔÚ°´ÕÕÓÅ»¯µÄÔÔò¶ÔÊý¾ÝÀàÐͽøÐÐÑϸñµÄ¼ì²é£¬µ«¿ª·¢
ÈËÔ ......