表1 mdsp_t_priceinfo
字段(spid,objectid,externalid,name_lang1)表2 t_cmp_content
字段(object_id,contentcode,type,folder_id,status)表3 t_cmp_contentext
字段(object_id,lang,name,idx,value)
表3里面的有一条这样的数据 反正带有这样的name='isThirdCP' 和 value='1'就屏蔽掉 这是我的SQL语句 大家看一下 那里有问题 (可以查询出来但是不理想)
select  * from mdsp_t_priceinfo tp inner join t_cmp_content c on tp.externalid = c.contentcode
where c.object_id not in (select t.object_id from t_cmp_contentext t 
where t.name = 'isThirdCP' and t.value = '1')
order by objectID desc;
谢谢了 解决分就到

解决方案 »

  1.   

    忘了说了 表1和表2 是这两个字段关联的 externalid(表1) contentcode(表2)
      

  2.   

    select tp.*
      from mdsp_t_priceinfo tp,
      t_cmp_content c 
    where 
           c.name <> 'isThirdCP'
        and c.value <> '1'
        and tp.externalid = c.contentcode(+)
        order by tp.objectID desc 
      
      

  3.   


    name和value是这张表的字段 t_cmp_content 不是这张表的
      

  4.   

    select tp.*
      from mdsp_t_priceinfo tp,
      t_cmp_content c  
    where  
      tp.name <> 'isThirdCP'
      and tp.value <> '1'
      and tp.externalid = c.contentcode(+)
      order by tp.objectID desc  
      

  5.   

    以为就2个表呢,看看下面这个,三个表关联,大概意思就是这样,你可以自己动手核对或者修改下
    select tp.*
      from mdsp_t_priceinfo tp,
      t_cmp_content c  ,
      t_cmp_contentext d
    where  
      d.name <> 'isThirdCP'
      and d.value <> '1'
      and tp.externalid = c.contentcode(+)  ---------这个是左连接
      and d.object_id = c.object_id   -------这个全连接么
      order by tp.objectID desc
      

  6.   


    兄弟很感谢你的回复 但是name和value不是mdsp_t_priceinfo表的 而是t_cmp_contentext表的 我上面有写的 
      

  7.   

    1、只给出SQL求优化,一般给不出什么好的建议。
    2、搜集所涉及的表的统计数据(dbms_stats.gather_table_stats)
    3、查看执行计划
    根据表上的索引情况和实际的执行计划来优化
      

  8.   

    select tp.*
      from mdsp_t_priceinfo tp,
      t_cmp_content c  ,
      t_cmp_contentext d    --------不就是这个表上的么。。
    where  
      d.name <> 'isThirdCP'
      and d.value <> '1'
      and tp.externalid = c.contentcode(+)  ---------这个是左连接
      and d.object_id = c.object_id   -------这个全连接么
      order by tp.objectID desc