sql語句應是:
select * from dq where pi_no in (select pi_no from pi)

解决方案 »

  1.   


    暂时没发现:-)把Index处理好吧~`````
      

  2.   

    各位:
    table1:pi  有20萬記錄 30MB
    table2:dq  有10萬記錄 10MB select * from dq where pi_no in (select pi_no from pi)
    要實現上述功能,有沒有效率更高的語句?
      

  3.   

    select dq.* form dq inner join pi on dq.pi_no = pi.pi_no两个表都要在这个字段上建立索引。
      

  4.   

    select * form dq 
    where exists (
    select 1 from pi 
    where  pi.pi_no=dq.pi_no
    )
      

  5.   

    索引很重要,两个表都要对pi_no键索引!
      

  6.   

    spring_ok(spring.z)的方法合适。
    在大数据量时用联接的效率高很多。
      

  7.   

    一般情况下,
    select * from dq where pi_no in (select pi_no from pi)
     比
    select * form dq where exists (select 1 from pi 
    where  pi.pi_no=dq.pi_no)的效率要低
    ,所以建议用 Yang_(扬帆破浪) 的方法
      

  8.   

    create clustered index idxpi_no on pi(pi_no)
    create clustered index idxpi_no on dq(pi_no)pi_no如果是其中一个表的外关键字,把上面一行中的clusted改成nonclusteredselect * from pi left outer join dq
    where pi.pi_no=dq.pi_no 
      

  9.   

    select * from dq 
    where exists(select * from pi where dq.pi_no=pi.pi_no)