oracle 优化or 替换为in、exists、union的几种写法,测试没有问题! 根据实际情况用选择相应的语句吧!如果有索引,or全表扫描,in 和not in 也要慎用,否则会导致全表扫描, select * from t_pro_product where bar_code = nnnmmm or name = nnnmmm or no =
oracle 优化or 替换为in、exists、union的几种写法,测试没有问题!
根据实际情况用选择相应的语句吧!如果有索引,or全表扫描,in 和not in 也要慎用,否则会导致全表扫描,
select * from t_pro_product where bar_code = 'nnnmmm' or name = 'nnnmmm' or no = 'nnnmmm';select * from t_pro_product where 'nnnmmm' in (bar_code, name, no) --忧化 select * from t_pro_product t1 where exists (select 1 from t_pro_product tt1 where t1.bar_code = 'nnnmmm' union all select 1 from t_pro_product tt2 where t1.no = 'nnnmmm' union all select 1 from t_pro_product tt3 where t1.name like 'n%') --忧化 select * from t_pro_product t1 where t1.id in (select id from t_pro_product tt1 where t1.bar_code = 'nnnmmm' union all select id from t_pro_product tt2 where t1.no = 'nnnmmm' union all select id from t_pro_product tt3 where t1.name = 'nnnmmm')