【Access】SQL语句中内连接的运用
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz/rlzBtFD4J7bHPL5whO9ForibWyuBWeicIwK0FrK76kvhbTtHpOSAXK2WEFeDUGB05S3sI1Chcbf8rPzZ4iaUf1R6A/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;"><span style="color: black;">大众</span>好,上次课程<span style="color: black;">咱们</span>讲了自然连接的<span style="color: black;">运用</span>,本节课再跟随<span style="color: black;">博主</span>来学习一下内连接。内连接的效果和等值连接是<span style="color: black;">同样</span>的,只<span style="color: black;">不外</span>在Access数据库中的操作不<span style="color: black;">同样</span>罢了,<span style="color: black;">这儿</span>先放上内连接的SQL语法格式:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">SELECT ……FROM 表1 INNER JOIN 表2 ON 表1.某字段 = 表2.某字段</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">在学习内连接之前,<span style="color: black;">博主</span><span style="color: black;">剧烈</span><span style="color: black;">意见</span>你重新温习一下等值连接的知识,<span style="color: black;">剧烈</span><span style="color: black;">意见</span>哦,<span style="color: black;">这般</span>待会儿才会有对比。</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">点击查看:<a style="color: black;"><span style="color: black;">【等值连接详解】</span></a></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span>假设<span style="color: black;">咱们</span>的Access数据库中有<span style="color: black;">这般</span>两张表,表一:有a、b、c三个字段;表二有c、d、e三个字段。<span style="color: black;">倘若</span>表一中的任意一个字段和表二中的任意一个字段之间有相同的值,就<span style="color: black;">能够</span><span style="color: black;">形成</span>内连接,<span style="color: black;">这般</span>其实<span style="color: black;">咱们</span>可以得到如下的九个内连接的<span style="color: black;">状况</span>:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.a=表二c</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.a=表二d</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.a=表二e</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.b=表二c</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.b=表二d</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.b=表二e</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.c=表二c</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.c=表二e</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一.c=表二e</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">上面这段话基本和之前等值连接课程的<span style="color: black;">同样</span>。<span style="color: black;">那样</span><span style="color: black;">怎样</span>在Access数据库中<span style="color: black;">运用</span>内连接来完成<span style="color: black;">查找</span>呢?<span style="color: black;">咱们</span>来看一个例子,如下图是两个表:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">表一:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/rlzBtFD4J7YzstqZWUsbutaSDEeOh0yTxCSIlibVNCJruNc0vHy3c2ORORHJmwT0XGHHTZCVaTTOibHyY4kRjM5Q/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">表二:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/rlzBtFD4J7YzstqZWUsbutaSDEeOh0yTibNsrZXId5RU8tia9flCcs8cnouqnJSSDko4mic982jibP1Kk3p328WJJA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">仔细观察一下,<span style="color: black;">咱们</span>会<span style="color: black;">发掘</span>有如下的等值<span style="color: black;">状况</span>:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">1、表一的a字段和表二c字段有相同的值5;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">2、表一的b字段和表二c字段有相同的值6;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">3、表一的b字段和表二d字段有相同的值6;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">4、表一的c字段和表二c字段有相同的值5和7;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">5、表一的c字段和表二d字段有相同的值7;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">6、表一的c字段和表二e字段有相同的值7;</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><span style="color: black;">此刻</span><span style="color: black;">咱们</span>随便<span style="color: black;">选择</span>其中的一种<span style="color: black;">状况</span>在Access中做一个内连接<span style="color: black;">查找</span>,<span style="color: black;">这儿</span>就<span style="color: black;">选取</span>第三种<span style="color: black;">状况</span>(表一的b字段和表二d字段有相同的值6)<span style="color: black;">做为</span>演示,在<span style="color: black;">查找</span>设计器中按如下操作:</p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/rlzBtFD4J7YzstqZWUsbutaSDEeOh0yTu6f1f4iblYibeHWAABNAKGZJdXD5u81KP8pZGs5WtrTl5LLKAOv8WmZA/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;"><span style="color: black;">重视</span>到<span style="color: black;">无</span>,<span style="color: black;">这儿</span>是直接用连接线直接拖动的,<span style="color: black;">重视</span>和等值连接对比一下,这个内连接对应的SQL语句是:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/rlzBtFD4J7YzstqZWUsbutaSDEeOh0yTdOnGJBlciaML464g34Ar4Pic9t5AXOkynAnE1aFZF6YKmEqVPAORSicCQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;"><span style="color: black;">咱们</span><span style="color: black;">能够</span>看到用SQL语句中<span style="color: black;">运用</span>的是INNER JOIN子句,<span style="color: black;">而后</span>用ON连接两个表的字段,这<span style="color: black;">便是</span>内连接,下图是这个内连接的结果:</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;"><img src="http://mmbiz.qpic.cn/mmbiz_png/rlzBtFD4J7YzstqZWUsbutaSDEeOh0yTyugdia7Rria4lv9kHqiaTjQkcCPOk989REOw7WicNF1PdgVYm8Xk6dBfXQ/640?wx_fmt=png&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;"><span style="color: black;">咱们</span><span style="color: black;">能够</span>看到内连接<span style="color: black;">亦</span>只是<span style="color: black;">选取</span>属性值相等的<span style="color: black;">哪些</span>元组,其他不相等的元组<span style="color: black;">一样</span>被舍弃掉了。</span></p>
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">综合来看,<span style="color: black;">博主</span>觉得内连接操作起来比等值连接更方便,<span style="color: black;">由于</span><span style="color: black;">咱们</span><span style="color: black;">能够</span>直接用拖动的方式把两个表中有相同值的字段连接起来就好了。<span style="color: black;">这儿</span>再次<span style="color: black;">意见</span>和等值连接好好做个对比。</p>快捷查看<span style="color: black;"><strong style="color: blue;"><span style="color: black;">平台回复数字“6”查看Access常规知识目录</span></strong></span><img src="http://mmbiz.qpic.cn/mmbiz/rlzBtFD4J7bkbMpYp6z2iaQOUgLR7wtBN0V589WntqDjjkPRQyOMv0D5oRerLhfpne4lHz1ibGVmKialGTT1XgADA/0?wx_fmt=gif&tp=webp&wxfrom=5&wx_lazy=1" style="width: 50%; margin-bottom: 20px;"><img src="http://mmbiz.qpic.cn/mmbiz/rlzBtFD4J7bkbMpYp6z2iaQOUgLR7wtBN24jrungXmsO2p7APFD1YfUia1pnGx0xicjiavA6T6rT1qAeVsf1OIo7nA/640?wx_fmt=jpeg&tp=webp&wxfrom=5&wx_lazy=1&wx_co=1" style="width: 50%; margin-bottom: 20px;">
<p style="font-size: 16px; color: black; line-height: 40px; text-align: left; margin-bottom: 15px;">职场办公,快人一步!</p><span style="color: black;">你有两种方式约这个<span style="color: black;">博主</span>:</span><strong style="color: blue;"><span style="color: black;">Q Q:</span></strong>2456917009<strong style="color: blue;"><span style="color: black;"><span style="color: black;">微X</span>:</span></strong>HC10000086
楼主发的这篇帖子,我觉得非常有道理。 可以发布外链的网站 http://www.fok120.com/ 谷歌网站排名优化 http://www.fok120.com/ 软文发布论坛开幕式圆满成功。 http://www.fok120.com 你的见解真是独到,让我受益匪浅。 太棒了、厉害、为你打call、点赞、非常精彩等。
页:
[1]