表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;
谢谢了 解决分就到
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
name和value是这张表的字段 t_cmp_content 不是这张表的
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
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
兄弟很感谢你的回复 但是name和value不是mdsp_t_priceinfo表的 而是t_cmp_contentext表的 我上面有写的
2、搜集所涉及的表的统计数据(dbms_stats.gather_table_stats)
3、查看执行计划
根据表上的索引情况和实际的执行计划来优化
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