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

mysqlº¯Êý»ã×Ü


Ò»¡¢
¿ØÖÆÁ÷³Ìº¯Êý
a)        
CASE WHEN THEN
º¯Êý
Óï·¨£º
CASE value WHEN [compare-value]
THEN result [WHEN [compare-value] THEN result ……] [ELSE result ] END CASE WHEN
[condition] THEN result [WHEN[condition] THEN result ……] [ELSE result] END
£»
º¯ÊýÓ÷¨ËµÃ÷£ºÔÚµÚÒ»¸ö·½°¸µÄ·µ»Ø½á¹ûÖУ¬
value
=compare-value
¡£¶øµÚ¶þ¸ö·½°¸µÄ·µ»Ø½á¹ûÊǵÚÒ»ÖÖÇé¿öµÄÕæʵ½á¹û¡£Èç¹ûûÓÐÆ¥ÅäµÄ½á¹ûÖµ£¬Ôò·µ»Ø½á¹ûΪ
ELSE
ºóµÄ½á¹û£¬Èç¹ûûÓÐ
ELSE
²¿·Ö£¬Ôò·µ»ØֵΪ
NULL
b)       
IF
º¯ÊýÓ÷¨
Óï·¨£º
IF(expr1,expr2,expr3)
º¯ÊýÓ÷¨ËµÃ÷£ºÈç¹û
expr1

ÊÇ
TRUE (expr1
<> 0 and expr1
<> NULL)
£¬Ôò
IF()
µÄ·µ»ØֵΪ
expr2
;
·ñÔò·µ»ØÖµÔòΪ
expr3
¡£
IF()
µÄ·µ»ØֵΪÊý×ÖÖµ»ò×Ö·û´®Öµ£¬¾ßÌåÇé¿öÊÓÆäËùÔÚÓï¾³¶ø¶¨
c)       
IFNULL
º¯Êý
Óï·¨£º
IFNULL(expr1,expr2)
º¯ÊýÓ÷¨ËµÃ÷£º¼ÙÈç
expr1

²»Îª
NULL
£¬Ôò
IFNULL()
µÄ·µ»ØֵΪ
expr1
;
·ñÔòÆä·µ»ØֵΪ
expr2
¡£
IFNULL()
µÄ·µ»ØÖµÊÇÊý×Ö»òÊÇ×Ö·û´®£¬¾ßÌåÇé¿öÈ¡¾öÓÚÆäËùʹÓõÄÓï¾³
¶þ¡¢
×Ö·û´®±È½Ïº¯Êý
a)        
º¯Êý
ascii(str)
º¯ÊýÓ÷¨ËµÃ÷£º·µ»ØֵΪ×Ö·û´®
str

µÄ×î×ó×Ö·ûµÄÊýÖµ¡£¼ÙÈç
str
Ϊ¿Õ×Ö·û´®£¬Ôò·µ»ØֵΪ
0
¡£¼ÙÈç
str

Ϊ
NULL
£¬Ôò·µ»ØֵΪ
NULL
¡£
ASCII()
ÓÃÓÚ´øÓдÓ
0
µ½
255
µÄÊýÖµµÄ×Ö·û
b)       
º¯Êý
BIN(N)
º¯ÊýÓ÷¨ËµÃ÷£º·µ»ØֵΪ
N
µÄ¶þ½øÖÆÖµµÄ×Ö·û´®±íʾ£¬ÆäÖÐ
  N

Ϊһ¸ö
longlong (BIGINT)
Êý×Ö¡£ÕâµÈͬÓÚ
CONV(N
,10,2)
¡£¼ÙÈç
N

Ϊ
NULL
£¬Ôò·µ»ØֵΪ
NULL
¡£
c)       
º¯ÊýCHAR(N
,...
[USING charset
])
º¯ÊýÓ÷¨ËµÃ÷£º
CHAR()
½«Ã¿¸ö²ÎÊý
N
Àí½âΪһ¸öÕûÊý£¬Æä·µ»ØֵΪһ¸ö°üº¬ÕâЩÕûÊýµÄ´úÂëÖµËù¸ø³öµÄ×Ö·ûµÄ×Ö·û´®¡£
NULL
Öµ±»Ê¡ÂÔ¡£
d)       
º¯ÊýCHAR_LENGTH(str
)
º¯ÊýʹÓÃ˵Ã÷£º·µ»ØֵΪ×Ö·û´®
str

µÄ³¤¶È£¬³¤¶ÈµÄµ¥Î»Îª×Ö·û¡£Ò»¸ö¶à×Ö½Ú×Ö·ûËã×÷


Ïà¹ØÎĵµ£º

11 advanced MySQL questions

 

Explain MySQL architecture
. - The front layer
takes care of network connections and security authentications, the
middle layer does the SQL query parsing, and then the query is handled
off to the storage engine. A storage engine could be either a default
one supp ......

mysql±äÁ¿ÀàÐÍ

9.3. Óû§±äÁ¿
¿ÉÒÔÏÈÔÚÓû§±äÁ¿Öб£´æֵȻºóÔÚÒÔºóÒýÓÃËü£»ÕâÑù¿ÉÒÔ½«Öµ´ÓÒ»¸öÓï¾ä´«µÝµ½ÁíÒ»¸öÓï¾ä¡£Óû§±äÁ¿ÓëÁ¬½ÓÓйØ
¡£Ò²¾ÍÊÇ˵£¬Ò»¸ö¿Í»§¶Ë¶¨ÒåµÄ±äÁ¿²»Äܱ»ÆäËü¿Í»§¶Ë¿´µ½»òʹÓᣵ±¿Í»§¶ËÍ˳öʱ£¬¸Ã¿Í»§¶ËÁ¬½ÓµÄËùÓбäÁ¿½«×Ô¶¯ÊÍ·Å¡£
Óû§±äÁ¿µÄÐÎʽΪ@var_name
£¬ÆäÖбäÁ¿Ãûvar_name
¿ÉÒÔÓɵ±Ç°×Ö· ......

php¡¢MySqlÔËÐл·¾³

ÕâÀï½éÉÜÒ»¸ö¼¯³É»·¾³ XAMPP¡£
XAMPP ÊÇÒ»¸öÒ×ÓÚ°²×°ÇÒ°üº¬ MySQL¡¢PHP ºÍ Perl µÄ Apache ·¢Ðа档XAMPP µÄÈ··Ç³£ÈÝÒ×°²×°ºÍʹÓãºÖ»ÐèÏÂÔØ£¬½âѹËõ£¬Æô¶¯¼´¿É¡£
ÏÂÔصØÖ·£º
http://www.apachefriends.org/zh_cn/xampp.html
µ½Ä¿Ç°ÎªÖ¹£¬XAMPP ¹²ÓÐÒÔÏÂËÄÖÖ°æ±¾£º
£¨1£©ÊÊÓÃÓÚ Linux µÄ XAMPP
£¨2£©ÊÊÓÃÓÚ Windows µ ......

MySql»ù´¡ÖªÊ¶(¾­µä°æ)

 
Ò»¡¢mysql µÄ¹ÜÀí
1
¡¢Á¬½Ó
Mysql
¸ñʽ£º mysql -hÖ÷»úµØÖ· -uÓû§Ãû £­pÓû§ÃÜÂë
Àý1£ºÁ¬½Óµ½±¾»úÉϵÄMYSQL¡£
Ê×ÏÈÔÚ´ò¿ªDOS´°¿Ú£¬È»ºó½øÈëĿ¼ mysqlbin£¬ÔÙ¼üÈëÃüÁîmysql -uroot -p£¬»Ø³µºóÌáʾÄãÊäÃÜÂ룬Èç¹û¸Õ°²×°ºÃMYSQL£¬³¬¼¶Óû§rootÊÇûÓÐÃÜÂëµÄ£¬¹ÊÖ±½Ó»Ø³µ¼´¿É½øÈëµ½MYSQLÖÐÁË£¬MYSQLµÄÌáʾ·ûÊÇ£º ......

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±ê ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ