select sno
from sc sc1
where exists(select sno
from sc sc2
where sc1.sno=sc2.sno and sc2.cno='c2' and sc2.cno='c1')
为什么上面的句子出错?而下面的就对了!
select sno
from sc sc1
where exists(select sno
from sc sc2
where sc1.sno=sc2.sno and sc2.cno='c2') and cno='c1'

解决方案 »

  1.   

    sc2.cno='c2' and sc2.cno='c1'
      

  2.   

    and sc2.cno='c2' and sc2.cno='c1'
    这样能出来结果?
      

  3.   

    运行楼主的第1句语句没有报错,只是结果集是空。
    楼主是不是全角、半角的问题啊,在全角下输入的脚本阿?
    select * from commodity a
    where exists (select com_name from commodity b where a.com_id=b.com_id and b.com_name='100元面膜' and b.com_name='穿山龙')
    (0 行受影响)
      

  4.   

    前面那句and sc2.cno='c2' and sc2.cno='c1'这样写肯定出错,一个字段能同时等于两个数?