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

mysql 优化语句

时间:2016-12-16 12:24:18      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:sql 优化

优化前:

select b.type, ifnull(count(0),0) as qty from b_sell_quotationd a,b_sell_quotation b 
where b.quotationNo=a.quotationNo and a.status=‘N‘ and b.companycode=‘XXXXX‘ AND b.type=‘general‘;

优化后:


select  COUNT(0) from b_sell_quotationd a LEFT JOIN (SELECT * FROM b_sell_quotation WHERE type=‘general‘) b ON b.quotationNo=a.quotationNo WHERE b.companycode=‘XXXXXX‘ and a.status=‘N‘

mysql 优化语句

标签:sql 优化

原文地址:http://4925054.blog.51cto.com/4915054/1883231

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