MySQL²»Ö§³ÖINTERSECTºÍMINUS£¬¼°ÆäÌæ´ú·½·¨
Doing INTERSECT and MINUS in MySQL
By Carsten | October 3, 2005
Doing an INTERSECT
An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So
SELECT member_id, name from a
INTERSECT
SELECT member_id, name from b
can simply be rewritten to
SELECT a.member_id, a.name
from a INNER JOIN b
USING (member_id, name)
Performing a MINUS
To transform the statement
SELECT member_id, name from a
MINUS
SELECT member_id, name from b
into something that MySQL can process, we can utilize subqueries (available from MySQL 4.1 onward). The easy-to-understand transformation is:
SELECT DISTINCT member_id, name
from a
WHERE (member_id, name) NOT IN
(SELECT member_id, name from table2);
Of course, to any long-time MySQL user, this is immediately obvious as the classical use-left-join-to-find-what-isn’t-in-the-other-table:
SELECT DISTINCT a.member_id, a.name
from a LEFT JOIN b USING (member_id, name)
WHERE b.member_id IS NULL
Ïà¹ØÎĵµ£º
×î½üÊÕµ½·´À¡£¬ºÜ¶à¿Í»§Á¬MySql¶¼ÎÞ·¨ÕýÈ·°²×°¡£ÊÕµ½ÈÎÎñ£¬Òª½«MySql´òµ½²úÆ·ÖУ¬ºÍ²úÆ·Ò»Æð°²×°ºÍжÔØ£¬À¿ª¼Ü
ʽ¸É°É£¬Ã»·¨×Ó¡£
Ñо¿Ò»Õ󣬷¢ÏÖ½«°²×°ºÃµÄMySqlÎļþ¼ÐCopyµ½ÆäËüµçÄÔÉÏ£¬ÔÙ½â¾öºÃÁ½¸öÎÊÌâÓ¦¸Ã¾Í¿ÉÒԺͰ²×°°æÒ»ÑùÕý³£Ê¹Óá£
1.Copyµ½ÁËÆäËüµçÄÔÉϵIJ»Í¬Ä¿Â¼£¬Ó¦¸ ......
1,Íü¼ÇrootÃÜÂë,Èç¹ûÄÜ»¹ÄܽøÈëmysqlÇÒ»¹ÓÐmysql¿âµÄȨÏÞ,ÄÇô¾ÍÖ±½ÓÖ´ÐÐ update user set password=password(¡®XXX¡¯) where user=¡¯root¡¯ and host=¡¯XX¡¯; flush privileges; ¼´¿É.Èç¹û²»ÄܽøÈëmysql,ÐèÒªÓÐmysqlÆô¶¯µÄȨÏÞ,ÔÚÆô¶¯mysqlµÄʱºò¼ÓÉÏ--skip-grant-tablesÑ¡Ïî,´Ëʱ½øÈëmysqlÎÞÐèÃÜÂë,ÔÙÖظ´ÉÏÊö²Ù ......
S- servÌáȨ·½Ê½ÈËÈ˶¼»áÓÃÁË£¬¸ãµÃÏÖÔÚµÄÖ÷»ú¶¼ÅäÖõ÷dz£°²È«£¬¿´À´¹¥»÷ÊÖ·¨µÄ²ã³ö²»ÇîÒ²ÊÇÔì³ÉÖйúÍøÂ簲ȫ½ø²½µÄÒ»´óÔÒòÖ®Ò»£¬»¹ÓÐÆäËûµÄ pcanywhere»ñÈ¡ÃÜÂ룬Ìæ»»·þÎñ£¬µÈµÈ¡£µ«ÊÇÏÖÔÚҲûÕâôºÃ¸ãÁË£¬Ëæ×Å°²È«ÒâʶµÄÌá¸ß£¬Ö®Ç°µÄ·½Ê½¹À¼Æ²»Ôõô¹ÜÓã¬ÏÖÔÚÎÒ¸ø´ó¼Ò½éÉÜÒ»ÏÂÒ»ÖÖеÄÌáȨ·½Ê½£¬¿´¹ý¹ÅµäLM×öµÄÄǶ¯»µÄ ......
1£® °²×°Cygwin
ÔËÐÐCygwinµÄ°²×°³ÌÐò¡£´ÓÎļû°üµÄµÄÁбíÖУ¬ÔÚDEVÀïÃ棬ȷ¶¨ÒªÑ¡Ôñ
• Ruby
• gcc
• subversion
ÄãÐèҪʹÓÃgccÀ´½¨Á¢Cygwin°æ±¾µÄMySQL.
2. ÔÚwindowsÉÏÃæ°²×°MYSQL£º
download MySQL 5.0 Windows Installer
3£® & ......
°æȨÉùÃ÷
£º×ªÔØʱÇëÒÔ³¬Á´½ÓÐÎʽ±êÃ÷ÎÄÕÂÔʼ³ö´¦ºÍ×÷ÕßÐÅÏ¢¼°±¾ÉùÃ÷
http://bbayou.blogbus.com/logs/37045617.html
²âÊÔÊý¾Ý2.5G£¬¹²ÓÐÊý¾Ý9427567Ìõ¡£ÓõÄmysqlµÄlarge·þÎñÆ÷µÄÅäÖá£
load
Ò»´ÎÐèÒª´ó¸Å10·ÖÖÓ×óÓÒ¡£
½¨µÄ±íÓõÄÊÇMYISAM£¬µ÷ÕûÁ˼¸¸ösessionµÄ²ÎÊýÖµ
SET
SESSION
BULK_INSERT_BUFFER_S ......