select sum(t1.sales) from Store_information t1 
  where t1.store_name 
  IN (Select Store_name from Geography t2 where t2.store_name = t1.store_name)以上sql文一运行就报错,有没有高手给解答一下是什么原因?

解决方案 »

  1.   

    你难道没看出来你的条件矛盾了吗?
    不知道你的需求,猜测一下。select sum(t1.sales) from Store_information t1,Geography t2 
      where t1.store_name = t2.store_name;
      

  2.   

    select sum(t1.sales) from Store_information t1  
      where t1.store_name  
      IN (Select Store_name from Geography t2 ,Store_information t1 where t2.store_name = t1.store_name)
      

  3.   

    LZ贴下错误吧,表示没看出来错误在哪。select sum(t.operid) from operskill t 
    where t.skillid in (
         select skillid from skillinfo t1 where t.skillid =t1.skillid
    );写了个类似的SQL表示无压力执行。
      

  4.   

      select sum(t1.sales) from Store_information t1  where t1.store_name in (select t2.store_name from geography t2 where t1.store_name = t2.store_name) 
    这个就好用  我没看出来和错误语句有什么区别
      

  5.   

    这个也是正确的  select sum(t1.sales) from Store_information t1  where t1.store_name in (select store_name from geography t2 where t1.store_name = t2.store_name) 
      

  6.   


    --別用in,效率低
    select sum(t1.sales) from Store_information t1  
      where exists (Select 1 from Geography t2 where t2.store_name = t1.store_name);
      

  7.   


    不过用 exists  就不能设置查询条件了where t1.store_name  的范围了