一个产品表
如果
select * from product where 产品名='book'
得到 产品名=book的所有记录但为什么select * form product as a where exists(select * from product where  产品名='book')
得到却是全部的纪录呢
望高人给与指点啊。
最后剩10分了,不好意思啊

解决方案 »

  1.   

    exists(select * from product where  产品名='book')的意思是
    select * from product where  产品名='book')有返回结果则条件成立
    那么,select * form product as a的结果当然是所有记录相当于
    select * form product as a where 1=1
      

  2.   

    是啊 exists(select * from product where  产品名='book')表示如果有记录返回就执行前面的 的会全部显示了
      

  3.   

    那为什么
    select * form product as a where exists(select * from product where id>a.id)
    得到的却是1,2,条纪录呢
    这里id是自增的编号,比如说是1, 2, 3 
    难道id>a.id不是等于id>1 or id>2 or id>3 吗
    如果不是那id>a.i要做何解呢
      

  4.   

    那为什么
    select * form product as a where exists(select * from product where id>a.id)
    得到的却是1,2,条纪录呢
    ----------------------------------
    楼主把3代入进去看看
    select * form product as a where exists(select * from product where id>3)
    因为exists(select * from product where id>3)里面id只有2>1,3>2,不可能3>3
    所以id=3的不成立