22,207
社区成员
发帖
与我相关
我的任务
分享
--in的方式---查询成本21.05%
select sum(money) from t_report_fee_details
where indicators_id in (select id from t_base_indicators where pid = 1) and report_id = 211
and type = 1
--连接的方式---查询成本36.84%
select sum(money) from t_report_fee_details as d
right join (select id from t_base_indicators where pid = 1)as m
on d.indicators_id=m.id and d.report_id = 211
and d.type = 1
--where(不增加在连接条件上)---查询成本21.05%
select sum(money) from t_report_fee_details as d
right join (select id from t_base_indicators where pid = 1)as m
on d.indicators_id=m.id where d.report_id = 211
and d.type = 1
--逗号的方式---查询成本21.05%
select
sum(money)
from t_report_fee_details as d
, (select id from t_base_indicators where pid = 1)as m
where d.indicators_id=m.id and d.report_id = 211 and d.type = 1
谢谢各位!select
sum(money)
from t_report_fee_details as d
, (select id from t_base_indicators where pid = 1)as m
on d.indicators_id=m.id and d.report_id = 211 and d.type = 1