sqlÖÐ×óÁ´½ÓºÍÓÒÁ´½ÓÓÐʲôÇø±ð
×óÁ´½Ó±£´æ×ó±íÐУ¬ÓÒÁ´½Ó±£´æÓÒ±íÐС£×óÁ´½ÓÔÚÓÒ±íûÓÐÆ¥ÅäÐеÄ×ó±íÐÐÖÐÌî³ä null£¬¶øÓÒÁ´½ÓÔÚ×ó±íûÓÐÆ¥ÅäÐеÄÓÒ±íÐÐÖÐÌî³ä null¡£
SQL ÖÐ×óÁ´½ÓºÍÓÒÁ´½ÓµÄÇø±ð
ÔÚ SQL ÖУ¬×óÁ´½ÓºÍÓÒÁ´½Ó¶¼ÊÇÅþÁ¬±íµÄ³£ÓòÙ×÷£¬µ«ËüÃÇÔÚÊý¾Ý¼ìË÷·½·¨Éϱ£´æÏÔ×Ųî±ð¡£
×óÁ´½Ó
±£´æ×ó±íÖеÄËùÓÐÐУ¬×ÝÈ»ÓÒ±íÖÐûÓÐÆ¥ÅäµÄ¼Í¼¡£
¹ØÓÚÓÒ±íÖÐûÓÐÆ¥Åä¼Í¼µÄ×ó±íÐУ¬ÓÒ±íÁеÄÖµ½«ÏÔʾΪ NULL¡£
ÅÌÎÊÓï·¨£º
SELECT * FROM left_table LEFT JOIN right_table ON left_table.key = right_table.key;
µÇ¼ºó¸´ÖÆ
ÓÒÁ´½Ó
±£´æÓÒ±íÖеÄËùÓÐÐУ¬×ÝÈ»×ó±íÖÐûÓÐÆ¥ÅäµÄ¼Í¼¡£
¹ØÓÚ×ó±íÖÐûÓÐÆ¥Åä¼Í¼µÄÓÒ±íÐУ¬×ó±íÁеÄÖµ½«ÏÔʾΪ NULL¡£
ÅÌÎÊÓï·¨£º
SELECT * FROM right_table RIGHT JOIN left_table ON left_table.key = right_table.key;
µÇ¼ºó¸´ÖÆ
Ö÷ÒªÇø±ð
±£´æÐУº×óÁ´½Ó±£´æ×ó±íÐУ¬ÓÒÁ´½Ó±£´æÓÒ±íÐС£
NULL Öµ£º×óÁ´½ÓÔÚÓÒ±íûÓÐÆ¥ÅäÐеÄ×ó±íÐÐÖÐÌî³ä NULL£¬¶øÓÒÁ´½ÓÔÚ×ó±íûÓÐÆ¥ÅäÐеÄÓÒ±íÐÐÖÐÌî³ä NULL¡£
ÒÔÉϾÍÊÇsqlÖÐ×óÁ´½ÓºÍÓÒÁ´½ÓÓÐʲôÇø±ðµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡