问题描述
我读到存在运算符不会返回数据,而是返回值true和false.即,如果existed查询中的条件为true或false.还存在并不检查每一行数据.一旦发现存在数据,则返回true,然后
第一个查询将相应地运行返回数据
但是事实并非如此.
在处理罗斯文数据库时
当我在查询后运行时,它返回了91行
从客户中选择customerid,companyname
但是当我在以下查询中使用exist运算符时,它仅返回89行
从存在的客户cu中选择customerid,companyname(从存在o.customerid = cu.customerid的订单o中选择orderid)
这意味着存在不仅检查特定数据集是否存在,还返回等于o.customerid
的所有cu.customer id.
请指导我有关Exists的信息
它返回什么值
I have read that the exists operator doesn''t return the data instead it returns the value true and false.i.e if condition in exist query is true or false. Also exist doesn''t check row by row data .As soon as it found that data exist it returns true and then
first query will run return data accordingly
however this was not the case .
when dealing with northwind database
when I was running following query it returned 91 rows
select customerid,companyname from customers
but when I used exist operator in following query it return only 89 rows
select customerid,companyname from customers cu where exists (select orderid from orders o where o.customerid=cu.customerid)
which means exist not only checks that particular set of data exist or not .it also returns all the cu.customer id which is equal to o.customerid
please Guide me regarding Exists operator
that what value it returns
推荐答案
这篇关于在SQL 2005中对Exists运算符的怀疑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!