kanoe.cn Open in urlscan Pro
42.194.226.214  Public Scan

Submitted URL: http://kanoe.cn/article/database/192.htm
Effective URL: https://kanoe.cn/article/database/192.htm
Submission: On June 25 via api from US — Scanned from DE

Form analysis 2 forms found in the DOM

Name: frmPOST blogcomm.asp

<form name="frm" action="blogcomm.asp" method="post" onsubmit="return checkCommentPost()" style="margin:0px;">
  <table width="100%" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td align="right" width="70"><strong>昵 称:</strong></td>
        <td align="left" style="padding:3px;"><input name="username" type="text" size="18" class="userpass" maxlength="24"></td>
      </tr>
      <tr id="passArea">
        <td align="right" width="70"><strong>密 码:</strong></td>
        <td align="left" style="padding:3px;"><input name="password" type="password" size="18" class="userpass" maxlength="24"> 游客发言不需要密码.</td>
      </tr>
      <tr>
        <td align="right" width="70" valign="top"><strong>内 容:</strong><br></td>
        <td style="padding:2px;">
          <script language="javascript" type="text/javascript" src="common/UBBCode.js"></script>
          <script language="javascript" type="text/javascript" src="common/UBBCode_help.js"></script>
          <div id="UBBSmiliesPanel" class="UBBSmiliesPanel"></div>
          <textarea id="editMask" class="editTextarea" style="width:99%;height:100px" onfocus="loadUBB('Message')"></textarea>
          <div id="editorbody" style="display:none">
            <div id="editorHead">正在加载编辑器...</div>
            <div class="editorContent">
              <textarea name="Message" class="editTextarea" style="height:150px;;" cols="1" rows="1" accesskey="R"></textarea>
            </div>
          </div>
        </td>
      </tr>
      <tr>
        <td align="right" width="70"><strong>验证码:</strong></td>
        <td align="left" style="padding:3px;"><input name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()">
          <img id="vcodeImg" src="common/getcode.asp?s=0.06665647144751197" onerror="this.onerror=null;this.src='common/getcode.asp?s='+Math.random();" alt="验证码" title="看不清楚?点击刷新验证码!"
            style="margin-right:40px;cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;" onclick="src='common/getcode.asp?s='+Math.random()">
        </td>
      </tr>
      <tr>
        <td align="right" width="70" valign="top"><strong>选 项:</strong></td>
        <td align="left" style="padding:3px;"><label for="label5">
            <input name="log_DisSM" type="checkbox" id="label5" value="1"> 禁止表情转换</label>
          <label for="label6">
            <input name="log_DisURL" type="checkbox" id="label6" value="1"> 禁止自动转换链接</label>
          <label for="label7">
            <input name="log_DisKey" type="checkbox" id="label7" value="1"> 禁止自动转换关键字</label>
        </td>
      </tr>
      <tr>
        <td colspan="2" align="center" style="padding:3px;">
          <input name="logID" type="hidden" value="192">
          <input name="action" type="hidden" value="post">
          <input name="submit2" type="submit" class="userbutton" value="发表评论" accesskey="S">
          <input name="button" type="reset" class="userbutton" value="重写">
        </td>
      </tr>
      <tr>
        <td colspan="2" align="right"> 虽然发表评论不用注册,但是为了保护您的发言权,建议您<a href="register.asp">注册帐号</a>. </td>
      </tr>
    </tbody>
  </table>
</form>

search.asp

<form style="MARGIN: 0px" onsubmit="if (this.SearchContent.value.length<3) {alert('关键字不能少于3个子');this.SearchContent.focus();return false}" action="search.asp"> 关键字 <input class="userpass" name="SearchContent">
  <div style="OVERFLOW: hidden; HEIGHT: 3px">&nbsp;</div> 类 型 <select name="searchType">
    <option value="title" selected="selected">日志标题</option>
    <option value="Content">日志内容</option>
    <option value="Comments">日志评论</option>
    <option value="trackback">引用通告</option>
  </select> <input class="userbutton" type="submit" value="查 找">
</form>

Text Content

独木舟
我的IT生活
 * 
 * Index
 * 
 * Database
 * 
 * Website
 * 
 * Coding
 * 
 * System
 * 
 * GIS
 * 
 * Live
 * 
 * TagsCloud
 * 
 * GuestBook
 * 
 * Album
 * 
 * KnowLedge
 * 

上一篇 | 下一篇
Database

01

13




SQL 外链接操作小结 INNER JOIN   LEFT JOIN   RIGHT JOIN


作者:独木舟 日期:2010-01-13

字体大小: 小 中 大

7. 外连接——交叉查询
7.1 查询
7.2 等值连接
7.3 右外连接
7.4 左外连接
7.5 更新操作

简介:

外部连接和自联接
inner join(等值连接) 只返回两个表中联结字段相等的行
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录
right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录
on 指定表间联结字段及其关系的等号 "=" 表达式, 返回 true 或 false. 当表达式返回 true 时, 则查询中包含该记录.
! 外部连接只能操作已存在于数据库中的数据

7.5.2

程序代码
Update (ctarticle AS a LEFT JOIN ctclass AS c ON a.classid = c.classid) LEFT
JOIN cttag AS b ON a.articleid = b.articleid
SET tag=tag+' ', b.articleid=a.articleid, b.classid=a.classid,
b.nclassid=a.nclassid
Where a.classid=23 AND a.nclassid=0 AND tagid is not null


7.5.1

程序代码
Update (ctarticle AS a LEFT JOIN (ctnclass AS c LEFT JOIN ctclass AS d ON
c.classid = d.classid) ON a.nclassid = c.nclassid AND a.classid = c.classid)
LEFT JOIN cttag AS b ON a.articleid = b.articleid SET tag=d.class+' '+c.nclass,
b.articleid=a.articleid, b.classid=a.classid, b.nclassid=a.nclassid Where
a.classid=23 AND a.nclassid=197;


7.5 更新操作

74.5 左连接中数据的筛选

程序代码
Insert INTO cttag(articleid,classid,nclassid) Select
a.articleid,a.classid,a.nclassid from ctarticle a left join cttag b on
a.articleid=b.articleid where b.articleid is null

//本语句功能为, 显示主表的全部内容, 插入数据到副表中没有的数据
//主要作用为: 让数据减少冗余

7.4.4.1 上例中的延续

程序代码
Select a.*, b.*, c.*, d.*
FROM cttag as d left join ((ctarticle AS a LEFT JOIN ctclass AS b ON
a.classid=b.classid) LEFT JOIN ctnclass AS c ON a.nclassid=c.nclassid) on
d.articleid=a.articleid;


7.4.4 显示文章表中的全部, 调用类别表中的栏目

程序代码
select a.*, b.*, c.* from (ctarticle a left join ctclass b on
a.classid=b.classid) left join ctnclass c on a.nclassid=c.nclassid

//作用, 有时在文章表中包含了在个别类别表中没有的数据, 用这个语法可以读出文章表的全部数据
//a 为 文章表, b 为主类别, c 为子类别

7.4.3 同上例, 选择追加数据时加上空格

程序代码
Insert INTO cttag(articleid,classid,nclassid,tag)
Select a.articleid,a.classid,a.nclassid,d.class+' '+c.nclass
FROM (ctarticle AS a left join (ctnclass c left join ctclass d on
c.classid=d.classid) on a.classid=c.classid and a.nclassid=c.nclassid) LEFT JOIN
cttag AS b ON a.articleid = b.articleid where a.classid=4 and a.nclassid=154;


7.4.2 连接N个表, 并追加数据到其中一个表, N=4

程序代码
Insert INTO cttag(articleid,classid,nclassid,tag)
Select a.articleid,a.classid,a.nclassid,d.class+c.nclass
FROM (ctarticle AS a left join (ctnclass c left join ctclass d on
c.classid=d.classid) on a.classid=c.classid and a.nclassid=c.nclassid) LEFT JOIN
cttag AS b ON a.articleid = b.articleid where a.classid=1 and a.nclassid=1;

//解读
插入到 表2(栏1,栏2,栏3,栏4)
选择 别名a.栏1, 别名a.栏2, 别名a.栏3, 别名d.栏4 加上 别名c.栏5
从 (表1 别名a 左连接 (表3 别名c 左连接 表4 别名d 在 别名c.栏2 等于 别名d.栏2) 在 别名a.栏2 等于 别名c.栏2 和
别名a.栏3=别名c.栏3) 左连接 表2 别名b 在 别名a.栏1 等于 别名b.栏1 在那里 别名a.栏2=1 和 别名a.栏3=1

7.4.1 连接两个表, 并追加数据到其中一个表

程序代码
Insert INTO cttag(articleid,classid,nclassid)
Select a.articleid,a.classid,a.nclassid
FROM ctarticle AS a LEFT JOIN cttag AS b ON a.articleid = b.articleid where
a.classid=1 and a.nclassid=1;

//解读
插入到 表2(栏1,栏2,栏3)
选择 别名a.栏1, 别名a.栏2, 别名a.栏3
从 表1 别名a 左连接 表2 别名b 在 别名a.栏1 等于 别名b.栏1 在那里 别名a.栏4=1 和 别名a.栏5=1

7.4. 左连接

7.3.1 同步两表的数据

程序代码
Update ctarticle a INNER JOIN cttag b ON a.articleid = b.articleid SET
b.classid=a.classid, b.nclassid=a.nclassid;

//解读
更新 表1 别名a 联接 表2 别名2 在 别名a.栏1 等于 别名b.栏1 设置 别名b.栏2 更新为 别名a.栏2, 别名b.栏3 更新为 别名a.栏3

7.3 右外连接

程序代码
select a.*, b.* from bunclass a right join ctclass b on a.classid=b.classid
where a.nclassid=20

查询别名 a,b 表, 只匹配 b 表中的内容.

7.2.3 添加数据到连接表之一

程序代码
Insert INTO cttag ( tag, articleid ) Select top 1 b.tag, a.articleid FROM
ctarticle AS a left JOIN cttag AS b ON a.articleid = b.articleid Where
a.articleid order by a.articleid desc;


7.2.2 变通中的用法二

程序代码
Insert INTO bureply
Select b.*, a.classid, a.nclassid
FROM article AS a INNER JOIN reply AS b ON a.articleid = b.articleid
Where classid=50;


7.2.1 实际应用中的变通

程序代码
Insert INTO butag ( tag, articleid, classid, nclassid)
Select b.tag, a.articleid, a.classid, a.nclassid
FROM article AS a INNER JOIN tag AS b ON a.articleid = b.articleid
Where classid=24;


7.2 添加数据到其他表

程序代码
Insert INTO butag ( tag, articleid )
Select b.tag, a.articleid
FROM article AS a INNER JOIN tag AS b ON a.articleid = b.articleid
Where a.articleid<>False;

//解读
添加到 接收表(列1,列2)
选择 别名b.列1, 别名a.列2
从 表1 表名a 联接 表2 表名b 在 别名a.列c 等于 别名b.列c
在哪里 别名a.列c 不等于 没有

7.1.1 实际应用中的变通

程序代码
Select b.tag, a.articleid, a.classid, a.nclassid
FROM article AS a INNER JOIN tag AS b ON a.articleid = b.articleid
Where a.classid=24;


7.1 查询

程序代码
Select b.tag, a.articleid
FROM article AS a INNER JOIN tag AS b ON a.articleid = b.articleid
Where a.articleid<>False;

//解读
选择 别名b.列, 别名a.列
从 表1 别名a 联接 表2 别名b 在 别名a.列c = 别名b.列c
在哪里 别名a.列c 不等于 没有
注: as 不是必要

7. 外连接——交叉查询
提示: 注意表中相同的栏目




文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: OracleOracle SQLSQL
相关日志:


评论: 2 | 引用: 0 | 查看次数: 1476
回复独木舟[2010-01-16 10:44 AM | ]
本来就系~
回复frankyhuang[2010-01-13 05:31 PM | ]
甘似我地大三学既数据库既!

发表评论

昵 称: 密 码: 游客发言不需要密码. 内 容:


正在加载编辑器...

验证码: 选 项: 禁止表情转换 禁止自动转换链接 禁止自动转换关键字 虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.



USER PANEL

登录用户注册


STATISTICS

日志: 228 篇
评论: 35 个
引用: 2 个
留言: 27 个
会员: 129 人
访问: 7477909 次
在线: 13 人
建站时间: 2007-10-26


RECENT COMMENTS

谢谢博主分享。pcre编译命令: gcc -o pcre_de...什么被你搞砸啦? [reply=独木舟,2010...沙发……
哈哈,别人就是我,帮忙种草的…… 我...一个字,傻 [reply=独木舟,2010-03...5明?
[reply=独木舟,2010-03-1...本来就系~甘似我地大三学既数据库既!Windows的不少东西貌似都是在中国研发哈哈,中国人就是牛


ARCHIVE

201202月201101月02月04月05月06月
08月10月201001月02月03月04月05月
07月10月11月12月200901月02月03月04月05月
06月07月08月09月10月
11月12月200803月04月05月06月07月
08月09月10月11月12月



SEARCH

关键字
 
类 型 日志标题 日志内容 日志评论 引用通告


LINKS

KnowLedgeWEB前端开发随风博客
更多链接…





Powered By PJBlog3 v3.0.6.170 CopyRight 2005 - 2008, 独木舟 xhtml | css

Processed in 0.062012 second(s) , 1 queries , iKK2 Design By Bighead.Lyf

粤ICP备18032989号

loading...