CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  MS-SQL Server >  基础类

两个表直接查询!帮忙

楼主avirm(我爱电视)2005-02-03 12:39:25 在 MS-SQL Server / 基础类 提问

表user  
      id,   bookid,dates  
  表info  
    id,   bookid2,isok  
   
  要求查询表user中的bookid在表info中的infoid里没相同数据的并且isok=1  
   
  为什么一下数据操作会把user中的记录都显示出来,  
  select   bookid   from   user   where   not   exists(select   bookid2   from   info   where   info.isok=1) 问题点数:20、回复次数:6Top

1 楼hdhai9451(☆新人类☆)回复于 2005-02-03 12:51:36 得分 10

//没相同数据  
   
  意思表達不清?不相同記錄還是不相同的bookid?根據你的意思,覺得應該這樣寫  
   
  select   bookid   from   user   where   bookid   not   in(select   bookid2   from   info   where   info.isok=1)  
  Top

2 楼xluzhong(Ralph)回复于 2005-02-03 13:00:23 得分 2

like   this?  
  select   bookid   from   user    
  where   bookid   not   in(select   bookid2   from   info)  
  and   isok=1Top

3 楼avirm(我爱电视)回复于 2005-02-03 13:09:35 得分 0

是这个意思,为什么使用   not   exists   不行Top

4 楼Qihua_wu(小吴)回复于 2005-02-03 13:23:25 得分 5

select   bookid   from   user     a   where   not   exists(select   bookid2   from   info   b   where   b.isok=1   and   a.bookid   =   b.bookid2)  
  Top

5 楼JafyLiu(自由的代价)回复于 2005-02-03 13:25:07 得分 3

not   exists应该也行,  
  select   bookid   from   user   where   not   exists(select   bookid2   from   user.id   =   info.id   and   info   where   info.isok=1)  
   
  Top

6 楼JafyLiu(自由的代价)回复于 2005-02-03 13:25:30 得分 0

not   exists应该也行,  
  select   bookid   from   user   where   not   exists(select   bookid2   from   user.id   =   info.id   and   info   where   info.isok=1)  
   
  Top

相关问题

  • 两表关连查询
  • 两个表关联查询
  • 两个表联合查询
  • 两表查询,在线等。
  • 两表查询问题
  • 两个表的查询?
  • 多表查询
  • 多表查询
  • 查询表
  • 查询表

关键词

  • 数据
  • bookid
  • isok
  • 表
  • info
  • 相同
  • 意思
  • not exists
  • where
  • user

得分解答快速导航

  • 帖主:avirm
  • hdhai9451
  • xluzhong
  • Qihua_wu
  • JafyLiu

相关链接

  • SQL Server类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo