当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: 最终的结果就是只能看见透明图片的不透明部分的图像,被透明的部分可以透过看见下面的东西 ......
 ·windows server 2003 减肥    »显示摘要«
    摘要: 系统盘我分配了10g空间,安装的东西我估计最多占了7g,现在只剩下700m了。不知道其他空间跑哪儿去了? ie 临时文件放到别处了,local setting,windows 下$ 临时文件内容删除了,不知道还有那里可以删除的。 ......


如何判斷一個表中某一個字段內的數量是否在另一個表中的某一個字段數據內.

如何判斷一個表中某一個字段內的數量是否在另一個表中的某一個字段數據內,  
  謝謝!  
  TABLE1  
  code   ,name  
    100,ss  
    101,aa  
    345,bb    
    653,dd  
  table2  
  code,other  
    100,   mmsdf  
    101,   asfsf  
    345,   asf  
    123,   afsaf  
  如上表所示要查詢出table2中字段CODE中的數據在TABLE1字段CODE中沒有的數據.  
  結果應該為  
      123,afsaf

NO.1   作者: danisluo

----建表  
  create   table   table1(code   nvarchar(3),name   nvarchar(10))  
  create   table   table2(code   nvarchar(3),other   nvarchar(10))  
  --生成测试数据  
  insert   into   table1   values   (100,ss)  
  insert   into   table1   values   (101,aa)  
  insert   into   table1   values   (345,bb)  
  insert   into   table1   values   (653,dd)  
  insert   into   table2   values   (100,mmsdf)  
  insert   into   table2   values   (101,asfsf)  
  insert   into   table2   values   (345,asf)  
  insert   into   table2   values   (123,afsaf)  
   
  --测试代码  
  select   *  
  from   table2  
  where   code   not   in(  
                                      select   code    
                                      from   table1  
                                    )    
   
  --运行结果  
  code       other  
  123         afsaf  
 

NO.2   作者: danisluo

方法2  
  select   *  
  from   table2   a  
  where   not   exists   (  
                                      select   *    
                                      from   table1   b  
                                      where   a.code=b.code  
                                    )


    摘要: 我的邮箱redmapple2002@163.com ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE