<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>INNER JOIN &#8211; 良的世界</title>
	<atom:link href="https://www.lemonary.cn/tag/inner-join/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.lemonary.cn</link>
	<description></description>
	<lastBuildDate>Wed, 08 Jan 2025 01:27:19 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.lemonary.cn/wp-content/uploads/2024/12/profile-150x150.jpg</url>
	<title>INNER JOIN &#8211; 良的世界</title>
	<link>https://www.lemonary.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>达梦数据库中的左外连接与内连接</title>
		<link>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e7%9a%84%e5%b7%a6%e5%a4%96%e8%bf%9e%e6%8e%a5%e4%b8%8e%e5%86%85%e8%bf%9e%e6%8e%a5/</link>
					<comments>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e7%9a%84%e5%b7%a6%e5%a4%96%e8%bf%9e%e6%8e%a5%e4%b8%8e%e5%86%85%e8%bf%9e%e6%8e%a5/#respond</comments>
		
		<dc:creator><![CDATA[shine]]></dc:creator>
		<pubDate>Wed, 08 Jan 2025 01:24:15 +0000</pubDate>
				<category><![CDATA[DM]]></category>
		<category><![CDATA[INNER JOIN]]></category>
		<category><![CDATA[LEFT JOIN]]></category>
		<guid isPermaLink="false">https://www.lemonary.cn/?p=1284</guid>

					<description><![CDATA[一、创建测试数据 二、左外连接 左外关联是获取左表全部结果集，以ON中的条件为限制，满足条件返回结果，不满足条 [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">一、创建测试数据</h2>



<pre class="wp-block-code"><code>CREATE TABLE LFINJI_A(ID NUMBER PRIMARY KEY, NAME VARCHAR2(20), ATYPE VARCHAR2(1));
CREATE TABLE LFINJI_B(ID NUMBER PRIMARY KEY, NAME VARCHAR2(20), BTYPE VARCHAR2(1));

INSERT INTO LFINJI_A VALUES (1,'AA' ,'1');
INSERT INTO LFINJI_A VALUES (2,'AB' ,'1');
INSERT INTO LFINJI_A VALUES (3,'AC' ,'0');
INSERT INTO LFINJI_A VALUES (4,'AD' ,'1');
INSERT INTO LFINJI_A VALUES (5,'AE' ,'0');
COMMIT;

INSERT INTO LFINJI_B VALUES (1,'BA' ,'1');
INSERT INTO LFINJI_B VALUES (2,'BB' ,'1');
INSERT INTO LFINJI_B VALUES (3,'BC' ,'1');
INSERT INTO LFINJI_B VALUES (5,'BD' ,'0');
INSERT INTO LFINJI_B VALUES (6,'BE' ,'1');
COMMIT;</code></pre>



<h2 class="wp-block-heading">二、左外连接</h2>



<p class="wp-block-paragraph">左外关联是获取左表全部结果集，以ON中的条件为限制，满足条件返回结果，不满足条件右表返回值填充为NULL。</p>



<pre class="wp-block-code"><code>SELECT A.ID, A.NAME, B.NAME FROM TEST_A A LEFT JOIN TEST_B B ON A.ATYPE = '1' AND A.ID = B.ID ;</code></pre>



<p class="wp-block-paragraph">结果集：</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="478" height="205" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-6.png" alt="" class="wp-image-1285" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-6.png 478w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-6-300x129.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></figure>



<h2 class="wp-block-heading">三、内连接</h2>



<p class="wp-block-paragraph">内连接只取满足条件的结果集相交部分。</p>



<pre class="wp-block-code"><code>SELECT A.ID, A.NAME, B.NAME FROM LFINJI_A A INNER JOIN LFINJI_B B ON A.ATYPE = '1' AND A.ID = B.ID ;</code></pre>



<p class="wp-block-paragraph">结果集：</p>



<figure class="wp-block-image size-full"><img decoding="async" width="478" height="106" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-7.png" alt="" class="wp-image-1286" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-7.png 478w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-7-300x67.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></figure>



<h2 class="wp-block-heading">另：不完全的左外连接</h2>



<p class="wp-block-paragraph">如果把过滤条件放在WHERE部分，并不算完全的左外连接，左表满足WHERE条件的会获取，右表不满足条件的会填充为NULL。</p>



<pre class="wp-block-code"><code>SELECT A.ID, A.NAME, B.NAME FROM LFINJI_A A LEFT JOIN LFINJI_B B ON A.ID = B.ID WHERE A.ATYPE = '1';</code></pre>



<p class="wp-block-paragraph">结果集：</p>



<figure class="wp-block-image size-full"><img decoding="async" width="478" height="139" src="https://www.lemonary.cn/wp-content/uploads/2025/01/image-8.png" alt="" class="wp-image-1287" srcset="https://www.lemonary.cn/wp-content/uploads/2025/01/image-8.png 478w, https://www.lemonary.cn/wp-content/uploads/2025/01/image-8-300x87.png 300w" sizes="(max-width: 478px) 100vw, 478px" /></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.lemonary.cn/%e8%be%be%e6%a2%a6%e6%95%b0%e6%8d%ae%e5%ba%93%e4%b8%ad%e7%9a%84%e5%b7%a6%e5%a4%96%e8%bf%9e%e6%8e%a5%e4%b8%8e%e5%86%85%e8%bf%9e%e6%8e%a5/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
