sqlÖÐwhereºÍonÄĸöÏÈÖ´ÐÐ
where ºÍ on ×Ó¾äµÄÖ´ÐÐ˳ÐòΪ£º1. where ×Ó¾äÏÈÖ´ÐУ¬¹ýÂ˳öÖª×ãÌõ¼þµÄÐС£2. È»ºó on ×Ó¾äÓ¦ÓÃÓÚÒѹýÂ˵ÄÐУ¬Æ¾Ö¤ÅþÁ¬Ìõ¼þ½¨ÉèÅþÁ¬¡£
SQL ÖÐ WHERE ºÍ ON ×Ó¾äµÄÖ´ÐÐ˳Ðò
ÔÚ SQL ÅÌÎÊÖУ¬WHERE ºÍ ON ×Ó¾äÊÇÓÃÓÚ¹ýÂËÊý¾Ý¼¯µÄÖ÷Òª½á¹¹¡£Ã÷È·ÕâÁ½ÖÖ×Ó¾äµÄÖ´ÐÐ˳Ðò¹ØÓÚÓÅ»¯ÅÌÎÊÐÔÄÜÖÁ¹ØÖ÷Òª¡£
Ö´ÐÐ˳Ðò£º
WHERE ×Ó¾äÔÚ ON ×Ó¾ä֮ǰִÐС£
ÏêϸڹÊÍ£º
WHERE ×Ó¾äÓ¦ÓÃÓÚÅÌÎÊÖеÄÕû¸ö±í£¬¹ýÂ˳öÖª×ãÖ¸¶¨Ìõ¼þµÄÐС£
ON ×Ó¾äÓÃÓÚÅþÁ¬±í£¬Ö¸¶¨ÅþÁ¬Ìõ¼þ£¬¼´ÄÄÐÐÓ¦¸ÃÆ¥Åä¡£
ÓÉÓÚ WHERE ×Ó¾äÔÚ ON ×Ó¾ä֮ǰӦÓã¬Òò´ËËüÊ×ÏȹýÂ˳öÖª×ãÆäÌõ¼þµÄÐС£
È»ºó£¬ON ×Ó¾ä¶ÔÒѹýÂ˵ÄÐÐÖ´ÐÐÅþÁ¬²Ù×÷£¬Æ¾Ö¤Öª×ãÆäÅþÁ¬Ìõ¼þµÄÐн¨ÉèÅþÁ¬¡£
ʾÀý£º
SELECT * FROM table1 WHERE column1 = 'value1' INNER JOIN table2 ON table1.column2 = table2.column3;
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÅÌÎÊÖУ¬WHERE ×Ó¾äÏȹýÂ˳ö table1 ÖÐ column1 ¼´ÊÇ value1 µÄÐС£È»ºó£¬ON ×Ó¾äÅþÁ¬ table1 ºÍ table2£¬Ìõ¼þÊÇ table1.column2 ¼´ÊÇ table2.column3¡£Ö»ÓÐͬʱ֪×ã WHERE ºÍ ON Ìõ¼þµÄÐвŻᱻ·µ»Ø¡£
Ã÷È·Ö´ÐÐ˳ÐòµÄÖ÷ÒªÐÔ£º
Ïàʶ WHERE ºÍ ON ×Ó¾äµÄÖ´ÐÐ˳ÐòÓÐÖúÓÚ±ÜÃâÅÌÎÊÖзºÆðÒâÍâЧ¹û¡£
ͨ¹ýÈ·±£ WHERE ×Ó¾ä¹ýÂ˳ö¸üÉÙµÄÊý¾ÝÐУ¬¿ÉÒÔÌá¸ßÅþÁ¬²Ù×÷µÄЧÂÊ¡£
ÓÅ»¯Ö´ÐÐ˳Ðò¿ÉÒÔͨ¹ýÔÚ WHERE ×Ó¾äÖÐʹÓÃË÷ÒýºÍÏÞÖÆ ON ×Ó¾äµÄÅþÁ¬Ìõ¼þÀ´ÊµÏÖ¡£
ÒÔÉϾÍÊÇsqlÖÐwhereºÍonÄĸöÏÈÖ´ÐеÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡