出错原因是
select x from tablea where column=(select b from tableb)
而子查询返回的结果不止一条按这个情况查询,有没有办法解决不出错又能查询到?

解决方案 »

  1.   

    select x from tablea where column=any(select b from tableb)
      

  2.   

    select x from tablea where column in(select b from tableb);
      

  3.   

    一般 “1 = N”时就会报这个错,看你的实际用途,是在一个范围内的话可以采用上述方法,这种错误也经常在DML 语句中出现!
      

  4.   

    select x from tablea where column=(select b from tableb where rownum=1)
      

  5.   

    SELECT a.x
      FROM tablea a, tableb b
     WHERE a.COLUMN = b.b
      

  6.   

    几种方法,效率各不同如2楼
    select x from tablea where column in(select b from tableb);还可以用EXISTS,大部分情况比IN的效率高
    select x from tablea  a where exists 
    (select 1 from tableb b
    where b.b=a.column
    );
      

  7.   

    1,select x from tablea where column=any(select b from tableb)2,select x from tablea where column in(select b from tableb);3,select x from tablea a where exists 
    (select 1 from tableb b
    where b.b=a.column
    );
    这三种方法,习惯用第三种,不知道具体的执行效率是怎么样的,请高人指教。