[Á°][¼¡][ÈÖ¹æ½ç°ìÍ÷][¥¹¥ì¥Ã¥É°ìÍ÷]

mysql:4295

From: fuji <fuji <fujiyama@xxxxxxxxxx>>
Date: Mon, 10 Sep 2001 22:41:12 +0900
Subject: [mysql 04295] Re: £²¥Æ¡¼¥Ö¥ë´Ö¤ÇÉÔ°ìÃפΥǡ¼¥¿¤òÃê½Ð¤·¤¿¤¤¡ª

fujiyama¤Ç¤¹¡£
²¿¤«Â¾¤ÎÊý¤¬¥ì¥¹¤ò¤Ä¤±¤Æ¤¯¤À¤µ¤Ã¤¿¤è¤¦¤Ç¤¹¤¬À޳ѽñ¤¤¤¿¤Î¤Ç¡¢¡¢¡¢

> ­¡SELECT DISTINCT user.userid 
> ¡¡FROM table1 LEFT JOIN table2 ON table1.userid=table2.userid,user 
> ¡¡WHERE table1.userid <> table2.userid
> 
> ­¢SELECT DISTINCT user.userid 
> ¡¡FROM table1 LEFT JOIN table2 ON table1.userid=table2.userid,user 
> ¡¡WHERE table2.userid is null
> 
> ­¡¤Îtable1.userid <> table2.userid
> ¤Ï¡¢¡Ötable1¤Çtable2¤ËÆþ¤Ã¤Æ¤¤¤Ê¤¤userid¤òÃê½Ð¤·¤¿¤¤¡£¡×
> ¤È¤¤¤¦¤Ä¤â¤ê¤Ç¤³¤¦½ñ¤­¤Þ¤·¤¿¡£
> 
> ­¡­¢¤Î°ã¤¤¤Ï¡¢ÆüËܸì¤Ç½ñ¤¯¤È¤É¤¦¤¤¤¦²ò¼á¤Ê¤ó¤Ç¤·¤ç¤¦¤«¡©
> 
> ¡Ötable1¤Çtable2¤ËÆþ¤Ã¤Æ¤¤¤Ê¤¤userid¤òÃê½Ð¤·¤¿¤¤¡£¡×
> ¤Î¾ì¹ç¡¢­¢¤¬Àµ¤·¤¤½ñ¤­Êý¤Ã¤Æ¤Î¤ÇLEFT JOIN¤ÎÍý²ò¤¬¤Þ¤¹¤Þ¤¹Æñ¤·¤¯¤Ê¤Ã¤Æ¤·¤Þ¤¤¤Þ¤·¤¿¡£¡£

»ÅÍͤǤϡ¢
¡Ö¤â¤·¡¢LEFT JOIN ¤Î ON ¤ä USING ¤Ë¤ª¤¤¤Æ±¦Â¦¤Î¥Æ¡¼¥Ö¥ë¤Ë¥Þ¥Ã¥Á¤¹¤ë¥ì¥³¡¼
¥É¤¬Ìµ¤«¤Ã¤¿¾ì¹ç¡¢Á´¤Æ¤Î¥Õ¥£¡¼¥ë¥É¤¬NULL¤Ç¤¢¤ë1¤Ä¤Î¥ì¥³¡¼¥É¤¬¡¢±¦Â¦¤Î¥Æ¡¼
¥Ö¥ë¤È¤·¤Æ»ÈÍѤµ¤ì¤Þ¤¹¡£¡×
¤È¤¢¤ê¤Þ¤¹¡£

¤Á¤ç¤Ã¤È¤Ö¤Ã¤Á¤ã¤±¤¿É½¸½¤·¤Þ¤¹¤¬¡¢
JOIN¹½Ê¸¤Ç¥Æ¡¼¥Ö¥ë¤ò¤¯¤Ã¤Ä¤±¤Þ¤¹¡£
LEFT JOIN¤Î¾ì¹ç¡¢º¸Â¦¤Î¥Æ¡¼¥Ö¥ë¡Ê¤³¤³¤Ç¤Ïtable1¡Ë¤Ë±¦Â¦¤Î¥Æ¡¼¥Ö¥ë
¡Êtable2)¤É¤¦¤ä¤Ã¤Æ¤¯¤Ã¤Ä¤±¤ë¤«¤Î¾ò·ï¤òON¶ç¤Ç»ØÄꤷ¤Þ¤¹¡£
¤³¤Î¾ì¹ç¤Ï¡¢ON¾ò·ï¤ÇƱ¤¸Ãͤò»ý¤Ã¤¿¥Õ¥£¡¼¥ë¥ÉƱ»Î¤ò·ë¤Ó¤Ä¤±¤Æ¤¤¤Þ¤¹¡£
¤³¤Î»þ¡¢table1¤Î¥Õ¥£¡¼¥ë¥É¤Ë¤¢¤ëÃͤ¬¡¢±¦Â¦¤Î¥Æ¡¼¥Ö¥ë¡Êtable2¡Ë¤Ë̵¤¤¾ì¹ç
¤âÅöÁ³¹Í¤¨¤é¤ì¤Þ¤¹¡£table1¤Ë²Ã¤¨¤ë¥Ç¡¼¥¿¤¬¤Ê¤¤¾õÂ֤Ǥ¹¡£
¤Ç¡¢Ãͤ¬¤¢¤ë¤È¤³¤í¤Ï¥Õ¥£¡¼¥ë¥ÉÍ­¤ê¡¢¤Ê¤¤¤È¤³¤í¤À¤±¥Õ¥£¡¼¥ë¥É¤Ê¤·¤Ê¤ó¤Æ¤¤
¤¦¤³¤È¤ÏDB¾åº¤¤ë¤Î¤Ç¡¢²¿¤«¥Õ¥£¡¼¥ë¥É¤ËÃͤòÆþ¤ì¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
»ÅÍͤǤÏNULLÃͤò¥Õ¥£¡¼¥ë¥É¤ËÆþ¤ì¤ë¤³¤È¤Ë¤·¤Þ¤·¤¿¡£

¤³¤ÎÊդϸÀÍÕ¤ÇÆɤó¤Ç¤â¿ʬ¤è¤¯Ê¬¤«¤é¤Ê¤¤¤Î¤Ç¡¢¼ÂºÝ¤ËSQL¤Ä¤¯¤Ã¤Æ½ÐÎϤµ¤»
¤Æ¤ß¤ë¤È¤¤¤¤¤È»×¤¤¤Þ¤¹¡£

Îã¡Ë
table1.userid
a               
b
c

table2.userid
a
b

SELECT table1.userid as t1 , table2.userid as t2 
 ¡¡FROM table1 LEFT JOIN table2 ON table1.userid=table2.userid;

SELECT table1.userid as t1 , table2.userid as t2 
 ¡¡FROM table1 JOIN table2;


¼Â¹ÔÎã
LEFT JOIN 
t1   t2
___________
a    a
b    b
c    NULL

JOIN
t1  t2
___________
a    a
a    b
b    a
b    b
c    a
c    b


¤Ç¡¢Àè¤ÎÎã¤À¤È½ÐÍè¾å¤¬¤Ã¤¿table2.userid¤ÇNULL¤Î¤â¤Î¤¬¤Ç¤­¤ë¤ï¤±¤Ç¤¹¡£
¤½¤·¤ÆNULL¤Î·×»»¤Ë¤Ä¤¤¤Æ¤Ç¤¹¤¬¡¢¤³¤ì¤ÏÈÉÀФµ¤ó¤Î½ñ¤¤¤Æ¤¤¤ë¤è¤¦¤Ë
¡ÖNULL ¤Ï¾¤ÎÁ´¤Æ¤ÎÃÍ(¤¿¤È¤¨ NULL ¤Ç¤â)¤ÈÈæ³Ó¤·¤¿»þ¤Ë¡¢¾ï¤Ëµ¶¤Ë¤Ê¤ëÃͤÇ
¤¹¡×
¤È¤¢¤ê¡¢¤Ä¤Þ¤êNULL¤ÏÈæ³Ó¤Ç¤­¤Þ¤»¤ó¡£
table2.userid¤ÏNULL¤¬Æþ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢ËÜÍè¡Ö¡ã¡ä¡×¤ÇÈæ³Ó¤Ï¤Ç¤­¤Ê¤¤¤Ï¤º¤È
¤¤¤¦¤³¤È¤Ç¤¹¡£
Èæ³Ó¤Ç¤­¤ë¤ó¤À¤Ã¤¿¤é¡Ê£±¡Ë¤Ç¤â¤¤¤¤¤È»×¤¤¤Þ¤¹¤è¡£

¡ô¡û£±=­¡¤Ïµ¡¼ï°Í¸ʸ»ú¤À¤½¤¦¤Ç¡¢ÀèÆüÃí°Õ¤·¤Ê¤µ¤¤¤È¸À¤ï¤ì¤Þ¤·¤¿(^^;


> >> ¡ö´Ø·¸¤Ê¤¤¤Ç¤¹¤±¤É¡¢php-4.0.6¤Îmail()´Ø¿ô¤¬»È¤¨¤Ê¤¯¤Æ¤Ï¤Þ¤Ã¤Æ¤Þ¤¹(;_:)

> »î¤·¤ËPROG_SENDMAIL=/var/qmail/bin/qmail-inject
> ¤òexport¤·¤Æ¤«¤é¡¢£Ð£È£Ð¤ò¥³¥ó¥Ñ¥¤¥ë¤·¤¿¤é
> º£Æü¡¢¾å¼ê¤¯¤¤¤­¤Þ¤·¤¿(^^)

¤³¤Á¤é¤Ï¤á¤Ç¤¿¤·¤á¤Ç¤¿¤·¡£

--¤ªÀ¤ÏäˤʤäƤ¤¤Þ¤¹ 
fuji <fujiyama@xxxxxxxxxx>


[Á°][¼¡][ÈÖ¹æ½ç°ìÍ÷][¥¹¥ì¥Ã¥É°ìÍ÷]

      4270 2001-09-03 16:18 ["yasushi fujiwara" <] £²¥Æ¡¼¥Ö¥ë´Ö¤ÇÉÔ°ìÃפΥǡ¼¥¿¤òÃê½Ð¤·¤¿¤¤¡ª
      4271 2001-09-03 16:54 ¨²[<endo_t@xxxxxxxxxx> ]                                       
      4272 2001-09-03 17:52 ¨²[madara <madara@xxxxx]                                       
      4273 2001-09-03 19:39 ¨­¨±["yasushi fujiwara" <]                                     
      4274 2001-09-03 19:54 ¨­¡¡¨²[fuji <fujiyama@xxxxx]                                   
      4277 2001-09-03 21:49 ¨­¡¡¨±[<endo_t@xxxxxxxxxx> ]                                   
      4278 2001-09-03 23:02 ¨­¡¡¡¡¨±["yasushi fujiwara" <]                                 
      4289 2001-09-09 08:15 ¨­¡¡¡¡¡¡¨±[<moeru@xxxxxxxxxx>  ]                               
      4290 2001-09-10 13:08 ¨­¡¡¡¡¡¡¡¡¨²[fuji <fujiyama@xxxxx]                             
      4292 2001-09-10 21:23 ¨­¡¡¡¡¡¡¡¡¨­¨±[<moeru@xxxxxxxxxx>  ]                           
      4293 2001-09-10 22:07 ¨­¡¡¡¡¡¡¡¡¨­¡¡¨²[<endo_t@xxxxxxxxxx> ]                         
      4294 2001-09-10 22:19 ¨­¡¡¡¡¡¡¡¡¨­¡¡¨²[¤È¤ß¤¿¤Þ¤µ¤Ò¤í <tomm]                         
->    4295 2001-09-10 22:41 ¨­¡¡¡¡¡¡¡¡¨­¡¡¨±[fuji <fujiyama@xxxxx]                         
      4298 2001-09-12 00:23 ¨­¡¡¡¡¡¡¡¡¨­¡¡¡¡¨±[<moeru@xxxxxxxxxx>  ]                       
      4291 2001-09-10 13:31 ¨­¡¡¡¡¡¡¡¡¨±[madara <madara@xxxxx]                             
      4275 2001-09-03 19:54 ¨±[Tomohiro 'Tomo-p' KA]