码迷,mamicode.com
首页 > 数据库 > 详细

多表关联sql查询优化

时间:2018-02-06 14:56:37      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:nbsp   ati   exist   查询   多表   org   表关联   1.4   sele   

select a from A a,B b where a.t=b.t

select a from A a where a.t in (select b.t from B b)

select distinct a.org_code,a.org_name from t_ORGANZATION a,T_DM_CDBP_ORGANZATION b where a.org_code=b.org_code;

select distinct a.org_code,a.org_name from t_ORGANZATION a where a.org_code in(select b.org_code from T_DM_CDBP_ORGANZATION b);

select distinct a.org_code,a.org_name from t_ORGANZATION a where EXISTS (select 1 from T_DM_CDBP_ORGANZATION b where a.org_code=b.org_code);

 

select

(*)1.523s

(1)1.459s

(t.id)1.36s

UNION ALL

多表关联sql查询优化

标签:nbsp   ati   exist   查询   多表   org   表关联   1.4   sele   

原文地址:https://www.cnblogs.com/vaio-430/p/8422277.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!