exists和no exists

 exists和no exists
http://hi.baidu.com/yds_amber/blog/item/0f64cfcf2c91b13bf8dc61d2.html

SELECT  *
FROM a left join b on a.id=b.id2
where not exists (select 1 from b b1 where b.id2 = b1.id2 and b.xh > b1.xh)

就是不在这个范围的意思
select id
from table
where name not exists(select 1
from table
where name = 'aaa')
也许你看不懂这个1的意思,不过在使用EXISTS的时候,通常都会使用1,它代表所查询出来的集合,等同

于select name。
整个例子的意思是:查询name不等于aaa的所有ID。


b.xh > b1.xh
这里是同一个表中字段相比较。是找出最小型了,可是怎么确定是那一产品的最小型号?
是不是外层的语句已经把范围定在某一产品了?

http://topic.csdn.net/u/20081107/15/307c24ec-062c-4daf-81ed-8df77ce97d7d.html?

seed=1355347129

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值