¡¡±¾ÎÄ̽ÌÖÁËÌá¸ßMySQL Êý¾Ý¿âÐÔÄܵÄ˼·£¬²¢´Ó8¸ö·½Ãæ¸ø³öÁ˾ßÌåµÄ½â¾ö·½·¨¡£
¡¡¡¡1¡¢Ñ¡È¡×îÊÊÓõÄ×Ö¶ÎÊôÐÔ
¡¡¡¡MySQL¿ÉÒԺܺõÄÖ§³Ö´óÊý¾ÝÁ¿µÄ´æÈ¡£¬µ«ÊÇÒ»°ã˵À´£¬Êý¾Ý¿âÖеıíԽС£¬ÔÚËüÉÏÃæÖ´ÐеIJéѯҲ¾Í»áÔ½¿ì¡£Òò´Ë£¬ÔÚ´´½¨±íµÄʱºò£¬ÎªÁË»ñµÃ¸üºÃµÄÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ½«±íÖÐ×ֶεĿí¶ÈÉèµÃ¾¡¿ÉÄÜС¡£ÀýÈ磬ÔÚ¶¨ÒåÓÊÕþ±àÂëÕâ¸ö×Ö¶Îʱ£¬Èç¹û½«ÆäÉèÖÃΪCHAR(255),ÏÔÈ»¸øÊý¾Ý¿âÔö¼ÓÁ˲»±ØÒªµÄ¿Õ¼ä£¬ÉõÖÁʹÓÃVARCHARÕâÖÖÀàÐÍÒ²ÊǶàÓàµÄ£¬ÒòΪCHAR(6)¾Í¿ÉÒԺܺõÄÍê³ÉÈÎÎñÁË¡£Í¬ÑùµÄ£¬Èç¹û¿ÉÒԵĻ°£¬ÎÒÃÇÓ¦¸ÃʹÓÃMEDIUMINT¶ø²»ÊÇBIGINÀ´¶¨ÒåÕûÐÍ×ֶΡ£
¡¡¡¡ÁíÍâÒ»¸öÌá¸ßЧÂʵķ½·¨ÊÇÔÚ¿ÉÄܵÄÇé¿öÏ£¬Ó¦¸Ã¾¡Á¿°Ñ×Ö¶ÎÉèÖÃΪ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 µÄ°æ±¾¿ªÊ¼Ö§³Ö UNION ²éѯ£¬Ëü¿ÉÒÔ°ÑÐèҪʹÓÃÁÙʱ±íµÄÁ½Ìõ»ò¸ü¶àµÄ SELECT ²éѯºÏ²¢µÄÒ»¸ö²éѯÖС£ÔÚ¿Í»§¶ËµÄ²éѯ»á»°½áÊøµÄʱºò£¬ÁÙʱ±í»á±»×Ô¶¯É¾³ý£¬´Ó¶ø±£Ö¤Êý¾Ý¿âÕûÆë¡¢¸ßЧ¡£Ê¹Óà UNION À´´´½¨²éѯµÄʱºò£¬ÎÒÃÇÖ»ÐèÒªÓà UNION×÷Ϊ¹Ø¼ü×ְѶà¸ö SELECT Óï¾äÁ¬½ÓÆðÀ´¾Í¿ÉÒÔÁË£¬Òª×¢ÒâµÄÊÇËùÓÐ SELECT Óï¾äÖеÄ×Ö¶ÎÊýÄ¿ÒªÏëͬ¡£ÏÂÃæµÄÀý×Ó¾ÍÑÝʾÁËÒ»¸öʹÓà UNIONµÄ²éѯ¡£
SELECT Name, Phone FROM client
UNION
SELECT Name, BirthDate FROM author
UNION
SELECT Name, Supplier FROM product
¡¡¡¡4¡¢ÊÂÎñ
¡¡¡¡¾¡¹ÜÎÒÃÇ¿ÉÒÔʹÓÃ×Ó²éѯ£¨Sub-Queries£©¡¢Á¬½Ó£¨JOIN£©ºÍÁªºÏ£¨UNION£©À´´´½¨¸÷ÖÖ¸÷ÑùµÄ²éѯ£¬µ«²»ÊÇËùÓеÄÊý¾Ý¿â²Ù×÷¶¼¿ÉÒÔÖ»ÓÃÒ»Ìõ»òÉÙÊý¼¸ÌõSQLÓï¾ä¾Í¿ÉÒÔÍê³ÉµÄ¡£¸ü¶àµÄʱºòÊÇÐèÒªÓõ½Ò»ÏµÁеÄÓï¾äÀ´Íê³ÉijÖÖ¹¤×÷¡£µ«ÊÇÔÚÕâÖÖÇé¿öÏ£¬µ±Õâ¸öÓï¾ä¿éÖеÄijһÌõÓï¾äÔËÐгö´íµÄʱºò£¬Õû¸öÓï¾ä¿éµÄ²Ù×÷¾Í»á±äµÃ²»È·¶¨ÆðÀ´¡£ÉèÏëһϣ¬Òª°Ñij¸öÊý¾Ýͬʱ²åÈëÁ½¸öÏà¹ØÁªµÄ±íÖУ¬¿ÉÄÜ»á³öÏÖÕâÑùµÄÇé¿ö£ºµÚÒ»¸ö±íÖгɹ¦¸üкó£¬Êý¾Ý¿âͻȻ³öÏÖÒâÍâ×´¿ö£¬Ôì³ÉµÚ¶þ¸ö±íÖеIJÙ×÷ûÓÐÍê³É£¬ÕâÑù£¬¾Í»áÔì³ÉÊý¾ÝµÄ²»ÍêÕû£¬ÉõÖÁ»áÆÆ»µÊý¾Ý¿âÖеÄÊý¾Ý¡£Òª±ÜÃâÕâÖÖÇé¿ö£¬¾ÍÓ¦¸ÃʹÓÃÊÂÎñ£¬ËüµÄ×÷ÓÃÊÇ£ºÒªÃ´Óï¾ä¿éÖÐÿÌõÓï¾ä¶¼²Ù×÷³É¹¦£¬ÒªÃ´¶¼Ê§°Ü¡£»»¾ä»°Ëµ£¬¾ÍÊÇ¿ÉÒÔ±£³ÖÊý¾Ý¿âÖÐÊý¾ÝµÄÒ»ÖÂÐÔºÍÍêÕûÐÔ¡£ÊÂÎïÒÔBEGIN ¹Ø¼ü×Ö¿ªÊ¼£¬COMMIT¹Ø¼ü×Ö½áÊø¡£ÔÚÕâÖ®¼äµÄÒ»ÌõSQL²Ù×÷ʧ°Ü£¬ÄÇô£¬ROLLBACKÃüÁî¾Í¿ÉÒÔ°ÑÊý¾Ý¿â»Ö¸´µ½BEGIN¿ªÊ¼Ö®Ç°µÄ״̬¡£
BEGIN;
INSERT INTO salesinfo SET CustomerID=14;
UPDATE inventory SET Quantity=11
WHERE item='book';
COMMIT;
¡¡¡¡ÊÂÎñµÄÁíÒ»¸öÖØÒª×÷ÓÃÊǵ±¶à¸öÓû§Í¬Ê±Ê¹ÓÃÏàͬµÄÊý¾ÝԴʱ£¬Ëü¿ÉÒÔÀûÓÃËø¶¨Êý¾Ý¿âµÄ·½·¨À´ÎªÓû§ÌṩһÖÖ°²È«µÄ·ÃÎÊ·½Ê½£¬ÕâÑù¿ÉÒÔ±£Ö¤Óû§µÄ²Ù×÷²»±»ÆäËüµÄÓû§Ëù¸ÉÈÅ¡£
¡¡¡¡5¡¢Ëø¶¨±í
¡¡¡¡¾¡¹ÜÊÂÎñÊÇά»¤Êý¾Ý¿âÍêÕûÐÔµÄÒ»¸ö·Ç³£ºÃµÄ·½·¨£¬µ«È´ÒòΪËüµÄ¶ÀÕ¼ÐÔ£¬ÓÐʱ»áÓ°ÏìÊý¾Ý¿âµÄÐÔÄÜ£¬ÓÈÆäÊÇÔںܴóµÄÓ¦ÓÃϵͳÖС£ÓÉÓÚÔÚÊÂÎñÖ´ÐеĹý³ÌÖУ¬Êý¾Ý¿â½«»á±»Ëø¶¨£¬Òò´ËÆäËüµÄÓû§ÇëÇóÖ»ÄÜÔÝʱµÈ´ýÖ±µ½¸ÃÊÂÎñ½áÊø¡£Èç¹ûÒ»¸öÊý¾Ý¿âϵͳֻÓÐÉÙÊý¼¸¸öÓû§
À´Ê¹Óã¬ÊÂÎñÔì³ÉµÄÓ°Ïì²»»á³ÉΪһ¸öÌ«´óµÄÎÊÌ⣻µ«¼ÙÉèÓгÉǧÉÏÍòµÄÓû§Í¬Ê±·ÃÎÊÒ»¸öÊý¾Ý¿âϵͳ£¬ÀýÈç·ÃÎÊÒ»¸öµç×ÓÉÌÎñÍøÕ¾£¬¾Í»á²úÉú±È½ÏÑÏÖصÄÏìÓ¦ÑÓ³Ù¡£
¡¡¡¡Æäʵ£¬ÓÐЩÇé¿öÏÂÎÒÃÇ¿ÉÒÔͨ¹ýËø¶¨±íµÄ·½·¨À´»ñµÃ¸üºÃµÄÐÔÄÜ¡£ÏÂÃæµÄÀý×Ó¾ÍÓÃËø¶¨±íµÄ·½·¨À´Íê³ÉÇ°ÃæÒ»¸öÀý×ÓÖÐÊÂÎñµÄ¹¦ÄÜ¡£
LOCK TABLE inventory WRITE
SELECT Quantity FROM inventory
WHEREItem='book';
...
UPDATE inventory SET Quantity=11
WHEREItem='book';
UNLOCK TABLES
¡¡¡¡ÕâÀÎÒÃÇÓÃÒ»¸ö SELECT Óï¾äÈ¡³ö³õʼÊý¾Ý£¬Í¨¹ýһЩ¼ÆË㣬Óà UPDATE Óï¾ä½«ÐÂÖµ¸üе½±íÖС£°üº¬ÓÐ WRITE ¹Ø¼ü×ÖµÄ LOCK TABLE Óï¾ä¿ÉÒÔ±£Ö¤ÔÚ UNLOCK TABLES ÃüÁî±»Ö´ÐÐ֮ǰ£¬²»»áÓÐÆäËüµÄ·ÃÎÊÀ´¶Ô inventory ½øÐвåÈë¡¢¸üлòÕßɾ³ýµÄ²Ù×÷¡£
¡¡¡¡6¡¢Ê¹ÓÃÍâ¼ü
¡¡¡¡Ëø¶¨±íµÄ·½·¨¿ÉÒÔά»¤Êý¾ÝµÄÍêÕûÐÔ£¬µ«ÊÇËüÈ´²»Äܱ£Ö¤Êý¾ÝµÄ¹ØÁªÐÔ¡£Õâ¸öʱºòÎÒÃǾͿÉÒÔʹÓÃÍâ¼ü¡£ÀýÈ磬Íâ¼ü¿ÉÒÔ±£Ö¤Ã¿Ò»ÌõÏúÊۼǼ¶¼Ö¸Ïòijһ¸ö´æÔڵĿͻ§¡£ÔÚÕâÀÍâ¼ü¿ÉÒÔ°Ñcustomerinfo ±íÖеÄCustomerIDÓ³Éäµ½salesinfo±íÖÐCustomerID£¬ÈκÎÒ»ÌõûÓкϷ¨CustomerIDµÄ¼Ç¼¶¼²»»á±»¸üлò²åÈëµ½salesinfoÖС£
CREATE TABLE customerinfo
(
CustomerID INT NOT NULL ,
PRIMARY KEY ( CustomerID )
) TYPE = INNODB;
CREATE TABLE salesinfo
(
SalesID INT NOT NULL,
CustomerID INT NOT NULL,
PRIMARY KEY(CustomerID, SalesID),
FOREIGN KEY (CustomerID) REFERENCES customerinfo
(CustomerID) ON DELETECASCADE
) TYPE = INNODB;
¡¡¡¡×¢ÒâÀý×ÓÖеIJÎÊý¡°ON DELETE CASCADE¡±¡£¸Ã²ÎÊý±£Ö¤µ± customerinfo ±íÖеÄÒ»Ìõ¿Í»§¼Ç¼±»É¾³ýµÄʱºò£¬salesinfo ±íÖÐËùÓÐÓë¸Ã¿Í»§Ïà¹ØµÄ¼Ç¼Ҳ»á±»×Ô¶¯É¾³ý¡£Èç¹ûÒªÔÚ MySQL ÖÐʹÓÃÍâ¼ü£¬Ò»¶¨Òª¼ÇסÔÚ´´½¨±íµÄʱºò½«±íµÄÀàÐͶ¨ÒåΪÊÂÎñ°²È«±í InnoDBÀàÐÍ¡£¸ÃÀàÐͲ»ÊÇ MySQL ±íµÄĬÈÏÀàÐÍ¡£¶¨ÒåµÄ·½·¨ÊÇÔÚ CREATE TABLE Óï¾äÖмÓÉÏ TYPE=INNODB¡£ÈçÀýÖÐËùʾ¡£
¡¡¡¡7¡¢Ê¹ÓÃË÷Òý
¡¡¡¡Ë÷ÒýÊÇÌá¸ßÊý¾Ý¿âÐÔÄܵij£Ó÷½·¨£¬Ëü¿ÉÒÔÁîÊý¾Ý¿â·þÎñÆ÷ÒÔ±ÈûÓÐË÷Òý¿ìµÃ¶àµÄËٶȼìË÷Ìض¨µÄÐУ¬ÓÈÆäÊÇÔÚ²éѯÓï¾äµ±Öаüº¬ÓÐMAX(), MIN()ºÍORDERBYÕâЩÃüÁîµÄʱºò£¬ÐÔÄÜÌá¸ß¸üΪÃ÷ÏÔ¡£ÄǸöÔÄÄЩ×ֶν¨Á¢Ë÷ÒýÄØ£¿Ò»°ã˵À´£¬Ë÷ÒýÓ¦½¨Á¢ÔÚÄÇЩ½«ÓÃÓÚJOIN, WHEREÅжϺÍORDER BYÅÅÐòµÄ×Ö¶ÎÉÏ¡£¾¡Á¿²»Òª¶ÔÊý¾Ý¿âÖÐij¸öº¬ÓдóÁ¿Öظ´µÄÖµµÄ×ֶν¨Á¢Ë÷Òý¡£¶ÔÓÚÒ»¸öENUMÀàÐ͵Ä×Ö¶ÎÀ´Ëµ£¬³öÏÖ´óÁ¿Öظ´ÖµÊǺÜÓпÉÄܵÄÇé¿ö£¬ÀýÈçcustomerinfoÖеġ°province¡±.. ×ֶΣ¬ÔÚÕâÑùµÄ×Ö¶ÎÉϽ¨Á¢Ë÷Òý½«²»»áÓÐʲô°ïÖú£»Ïà·´£¬»¹ÓпÉÄܽµµÍÊý¾Ý¿âµÄÐÔÄÜ¡£ÎÒÃÇÔÚ´´½¨±íµÄʱºò¿ÉÒÔͬʱ´´½¨ºÏÊʵÄË÷Òý£¬Ò²¿ÉÒÔʹÓÃALTER TABLE»òCREATE INDEXÔÚÒÔºó´´½¨Ë÷Òý¡£´ËÍ⣬MySQL
´Ó°æ±¾3.23.23¿ªÊ¼Ö§³ÖÈ«ÎÄË÷ÒýºÍËÑË÷¡£È«ÎÄË÷ÒýÔÚMySQL ÖÐÊÇÒ»¸öFULLTEXTÀàÐÍË÷Òý£¬µ«½öÄÜÓÃÓÚMyISAM ÀàÐÍµÄ±í¡£¶ÔÓÚÒ»¸ö´óµÄÊý¾Ý¿â£¬½«Êý¾Ý×°Ôص½Ò»¸öûÓÐFULLTEXTË÷ÒýµÄ±íÖУ¬È»ºóÔÙʹÓÃALTER TABLE»òCREATE INDEX´´½¨Ë÷Òý£¬½«ÊǷdz£¿ìµÄ¡£µ«Èç¹û½«Êý¾Ý×°Ôص½Ò»¸öÒѾÓÐFULLTEXTË÷ÒýµÄ±íÖУ¬Ö´Ðйý³Ì½«»á·Ç³£Âý¡£
¡¡¡¡8¡¢ÓÅ»¯µÄ²éѯÓï¾ä
¡¡¡¡¾ø´ó¶àÊýÇé¿öÏ£¬Ê¹ÓÃË÷Òý¿ÉÒÔÌá¸ß²éѯµÄËٶȣ¬µ«Èç¹ûSQLÓï¾äʹÓò»Ç¡µ±µÄ»°£¬Ë÷Òý½«ÎÞ·¨·¢»ÓËüÓ¦ÓеÄ×÷Óá£ÏÂÃæÊÇÓ¦¸Ã×¢ÒâµÄ¼¸¸ö·½Ãæ¡£Ê×ÏÈ£¬×îºÃÊÇÔÚÏàͬÀàÐ͵Ä×ֶμä½øÐбȽϵIJÙ×÷¡£ÔÚMySQL 3.23°æ֮ǰ£¬ÕâÉõÖÁÊÇÒ»¸ö±ØÐëµÄÌõ¼þ¡£ÀýÈç²»Äܽ«Ò»¸ö½¨ÓÐË÷ÒýµÄINT×ֶκÍBIGINT×ֶνøÐбȽϣ»µ«ÊÇ×÷ΪÌØÊâµÄÇé¿ö£¬ÔÚCHARÀàÐ͵Ä×ֶκÍVARCHARÀàÐÍ×ֶεÄ×ֶδóСÏàͬµÄʱºò£¬¿ÉÒÔ½«ËüÃǽøÐбȽϡ£Æä´Î£¬ÔÚ½¨ÓÐË÷ÒýµÄ×Ö¶ÎÉϾ¡Á¿²»ÒªÊ¹Óú¯Êý½øÐвÙ×÷¡£
¡¡¡¡ÀýÈ磬ÔÚÒ»¸öDATEÀàÐ͵Ä×Ö¶ÎÉÏʹÓÃYEAE()º¯Êýʱ£¬½«»áʹË÷Òý²»ÄÜ·¢»ÓÓ¦ÓеÄ×÷Óá£ËùÒÔ£¬ÏÂÃæµÄÁ½¸ö²éѯËäÈ»·µ»ØµÄ½á¹ûÒ»Ñù£¬µ«ºóÕßÒª±ÈÇ°Õß¿ìµÃ¶à¡£
SELECT * FROM order WHERE YEAR(OrderDate)<2001;
SELECT * FROM order WHERE OrderDate<"2001-01-01";
¡¡¡¡Í¬ÑùµÄÇéÐÎÒ²»á·¢ÉúÔÚ¶ÔÊýÖµÐÍ×ֶνøÐмÆËãµÄʱºò£º
SELECT * FROM inventory WHERE Amount/7<24;
SELECT * FROM inventory WHERE Amount<24*7;
¡¡¡¡ÉÏÃæµÄÁ½¸ö²éѯҲÊÇ·µ»ØÏàͬµÄ½á¹û£¬µ«ºóÃæµÄ²éѯ½«±ÈÇ°ÃæµÄÒ»¸ö¿ìºÜ¶à¡£µÚÈý£¬ÔÚËÑË÷×Ö·ûÐÍ×Ö¶Îʱ£¬ÎÒÃÇÓÐʱ»áʹÓà LIKE ¹Ø¼ü×ÖºÍͨÅä·û£¬ÕâÖÖ×ö·¨ËäÈ»¼òµ¥£¬µ«È´Ò²ÊÇÒÔÎþÉüϵͳÐÔÄÜΪ´ú¼ÛµÄ¡£ÀýÈçÏÂÃæµÄ²éѯ½«»á±È½Ï±íÖеÄÿһÌõ¼Ç¼¡£
SELECT * FROM books
WHERE name like "MySQL%"
¡¡¡¡µ«ÊÇÈç¹û»»ÓÃÏÂÃæµÄ²éѯ£¬·µ»ØµÄ½á¹ûÒ»Ñù£¬µ«ËٶȾÍÒª¿ìÉϺࣺܶ..
SELECT * FROM books
WHERE name>="MySQL"and name<"MySQM"
¡¡¡¡×îºó£¬Ó¦¸Ã×¢Òâ±ÜÃâÔÚ²éѯÖÐÈÃMySQL½øÐÐ×Ô¶¯ÀàÐÍת»»£¬ÒòΪת»»¹ý³ÌÒ²»áʹË÷Òý±äµÃ²»Æð×÷Óá£
robertmaggie ÓÚ 2007-12-25 14:19:39·¢±í:
Ö§³Ö
flycocoon ÓÚ 2006-07-26 16:12:00·¢±í:
²»´í£¬ÈÈÇÐÖ§³ÖÖÐ