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

·Ç³£²»´íµÄMySQLÓÅ»¯µÄ8Ìõ¾­Ñé

1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ

MySQL
¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«
±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁʹÓÃ
VARCHARÕâÖÖÀàÐÍÒ²ÊǶàÓàµÄ£¬ÒòΪCHAR(6)
¾Í¿ÉÒԺܺõÄÍê³ÉÈÎÎñÁË¡£Í¬ÑùµÄ£¬Èç¹û¿ÉÒԵĻ°£¬ÎÒÃÇÓ¦¸ÃʹÓÃMEDIUMINT¶ø²»ÊÇBIGINTÀ´¶¨ÒåÕûÐÍ×ֶΡ£
ÁíÍâÒ»¸öÌá¸ßЧÂʵķ½·¨ÊÇÔÚ¿ÉÄܵÄÇé¿öÏ£¬Ó¦¸Ã¾¡Á¿°Ñ×Ö¶ÎÉèÖÃΪNOT NULL£¬ÕâÑùÔÚ½«À´Ö´ÐвéѯµÄʱºò£¬Êý¾Ý¿â²»ÓÃÈ¥±È½ÏNULLÖµ¡£
¶ÔÓÚijЩÎı¾×ֶΣ¬ÀýÈç“Ê¡·Ý”»òÕß“ÐԱ𔣬ÎÒÃÇ¿ÉÒÔ½«ËüÃǶ¨ÒåΪENUMÀàÐÍ¡£ÒòΪÔÚMySQLÖУ¬ENUMÀàÐͱ»µ±×÷ÊýÖµÐÍÊý¾ÝÀ´´¦Àí£¬¶øÊýÖµÐÍÊý¾Ý±»´¦ÀíÆðÀ´µÄËÙ¶ÈÒª±ÈÎı¾ÀàÐÍ¿ìµÃ¶à¡£ÕâÑù£¬ÎÒÃÇÓÖ¿ÉÒÔÌá¸ßÊý¾Ý¿âµÄÐÔÄÜ¡£
2¡¢Ê¹ÓÃÁ¬½Ó£¨JOIN£©À´´úÌæ×Ó²éѯ(Sub-Queries)

MySQL
´Ó4.1¿ªÊ¼Ö§³ÖSQLµÄ×Ó²éѯ¡£Õâ¸ö¼¼Êõ¿ÉÒÔʹÓÃSELECTÓï¾äÀ´´´½¨Ò»¸öµ¥ÁеIJéѯ½á¹û£¬È»ºó°ÑÕâ¸ö½á¹û×÷Ϊ¹ýÂËÌõ¼þÓÃÔÚÁíÒ»¸ö²éѯÖС£ÀýÈ磬ÎÒÃÇ
Òª½«¿Í»§»ù±¾ÐÅÏ¢±íÖÐûÓÐÈκζ©µ¥µÄ¿Í»§É¾³ýµô£¬¾Í¿ÉÒÔÀûÓÃ×Ó²éѯÏÈ´ÓÏúÊÛÐÅÏ¢±íÖн«ËùÓз¢³ö¶©µ¥µÄ¿Í»§IDÈ¡³öÀ´£¬È»ºó½«½á¹û´«µÝ¸øÖ÷²éѯ£¬ÈçÏÂËùʾ£º
DELETE from customerinfo WHERE CustomerID NOT IN (SELECT CustomerID from salesinfo);
ʹÓÃ×Ó²éѯ¿ÉÒÔÒ»´ÎÐÔµÄÍê³ÉºÜ¶àÂß¼­ÉÏÐèÒª¶à¸ö²½Öè²ÅÄÜÍê³ÉµÄSQL²Ù×÷£¬Í¬Ê±Ò²¿ÉÒÔ±ÜÃâÊÂÎñ»òÕß±íËøËÀ£¬²¢ÇÒдÆðÀ´Ò²ºÜÈÝÒס£µ«ÊÇ£¬ÓÐЩÇé¿öÏ£¬×Ó²éѯ¿ÉÒÔ±»¸üÓÐЧÂʵÄÁ¬½Ó£¨JOIN£©Ìæ´ú¡£ÀýÈ磬¼ÙÉèÎÒÃÇÒª½«ËùÓÐûÓж©µ¥¼Ç¼µÄÓû§È¡³öÀ´£¬¿ÉÒÔÓÃÏÂÃæÕâ¸ö²éѯÍê³É£º
SELECT * from customerinfo WHERE CustomerID NOT IN (Select CustomerID from salesinfo);
Èç¹ûʹÓÃÁ¬½Ó£¨JOIN£©À´Íê³ÉÕâ¸ö²éѯ¹¤×÷£¬ËٶȽ«»á¿ìºÜ¶à¡£ÓÈÆäÊǵ±salesinfo±íÖжÔCustomerID½¨ÓÐË÷ÒýµÄ»°£¬ÐÔÄܽ«»á¸üºÃ£¬²éѯÈçÏ£º
SELECT
* from customerinfo LEFT JOIN salesinfoON
customerinfo.CustomerID=salesinfo. CustomerID WHERE
salesinfo.CustomerID IS NULL;
Á¬½Ó£¨JOIN£©Ö®ËùÒÔ¸üÓÐЧÂÊһЩ£¬ÊÇÒòΪMySQL²»ÐèÒªÔÚÄÚ´æÖд´½¨ÁÙʱ±íÀ´Íê³ÉÕâ¸öÂß¼­ÉϵÄÐèÒªÁ½¸ö²½ÖèµÄ²éѯ¹¤×÷¡£
3¡¢Ê¹ÓÃÁªºÏ(UNION)À´´úÌæÊÖ¶¯´´½¨µÄÁÙʱ±í

MySQL
´Ó4.0µÄ°æ±¾¿


Ïà¹ØÎĵµ£º

mysqlÖÐÎÄÂÒÂë½â¾ö

ÓÉÓÚÄÜÖ±½ÓÔÚMYSQLÊý¾Ý¿âÀïÌí¼ÓÖÐÎÄÊý¾Ý,²¢ÇÒÄÜÕý³£ÏÔʾ,˵Ã÷ÎÒµÄ±í¶¼Ê¹ÓÃÁËÕýÈ·µÄ×Ö·û±àÂë,¾­¹ý²é¿´ºó,È·ÈÏÁË,ÎÒÈ«²¿µÄ±íÒÔ¼°×ֶζ¼Ê¹ÓÃÁËUTF-8µÄ±àÂë,µ«ÊÇΪʲô³ÌÐòÌí¼ÓµÄÖÐÎÄÊý¾Ý¾Í²»ÐÐÄØ?
Æäʵ,Ô­ÒòÔÚÓÚMYSQL·þÎñÆ÷ʹÓõÄĬÈϱàÂë,ÒÔ¼°Êý¾Ý¿âµÄĬÈϱàÂë,ºÜ¶àÈËÒѾ­ºÜСÐĵÄÔÚ½¨Á¢±íʱ¹Ø×¢±íµÄ×Ö·û±àÂë,È´ºöÂÔÁËÊý¾Ý¿â ......

MysqlµÄGROUP_CONCAT()º¯ÊýʹÓ÷½·¨ ¶àÐкϲ¢º¯Êý

GROUP_CONCAT ÊÇÒ»¸öºÏ²¢¶àÐеĺ¯Êý£¬Ò»°ãÓõÄÉÙ£¬ËùÒԺܶàÈ˶¼²»ÖªµÀ£¬ÎÒÒ²ÊÇÒ»¸ö£¬½ñÌìżȻ¿´µ½£¬¹Ê¼ÇÏ·½·¨£»
GROUP_CONCATµÄÓï·¨ÈçÏ£º
GROUP_CONCAT([DISTINCT] expr [,expr ...][ORDER BY {unsigned_integer | col_name | expr}[ASC | DESC] [,col_name ...]][SEPARATOR str_val])
ÏÂÃæÑÝʾһÏÂÕâ¸öº¯Êý£¬ÏȽ¨Á¢Ò ......

Ö§³ÖMySqlÒ»°Ñ

ÒÔÏÂת×Ô Osss.cn Óʼþ£¬ÇëʹÓùý¡¢ÕýÔÚʹÓûòÕßÖ§³Ö¿ªÔ´µÄÅóÓÑÖ§³ÖÒ»ÏÂMySql£¬Ð»Ð»¡£

ҲϣÍû½ÌÓý²¿¡¢¿Æ¼¼²¿¸øÓèÖ±½ÓÖ§³Ö£¡


´ó¼ÒºÃ£º½ñÌì¿´µ½ÕâÔòÐÂÎÅ£¬Óë´ó¼Ò¹²Ïíһϣ¬MySQL´´Ê¼ÈËÏ£ÍûÖйúÉÌÎñ²¿ÄܽéÈëOracle&SunÊÕ¹º°¸£¬ºÃÏñ²¢Ã»ÓÐʵÖʽøÕ¹¡£¶ø¶íÂÞ˹Áª°î·´Â¢¶Ï»ú¹¹ÔÚÉÏÖÜÕ¹¿ªµ÷²é¡£Èç¹ûÐèÒªÉÌÎñ² ......

mysql¾ÖÓòÍø·ÃÎÊ

1,ÔÚwindow×Ô´øµÄ·À»ðǽÀïµÄÀýÍâÌí¼Ó3306¶Ë¿Ú£¬ÎªTCP
2£¬½ñÌìÔÚÓÃÔ¶³ÌÁ¬½ÓMysql·þÎñÆ÷µÄÊý¾Ý¿â£¬²»¹ÜÔõôŪ¶¼ÊÇÁ¬½Ó²»µ½£¬´íÎó´úÂëÊÇ1130£¬ERROR 1130: Host 192.168.2.159 is not allowed to connect to this MySQL server
²ÂÏëÊÇÎÞ·¨¸øÔ¶³ÌÁ¬½ÓµÄÓû§È¨ÏÞÎÊÌâ¡£½á¹ûÕâÑù×Ó²Ù×÷mysql¿â£¬¼´¿É½â¾ö¡£ÔÚ±¾»úµÇÈëmysqlºó£¬¸ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ