关于优化sql查询的一个方法。

select * from gmvcsbase.base_file file,gmvcsbase.base_user user,gmvcsbase.base_department dep,gmvcsbase.base_workstation work
where file.police_id=user.police_id and user.dep_code=dep.code and file.workstation_sid=work.sid and file.capture_time>=‘2013-10-30‘
AND file.capture_time<=‘2014-03-19 23:59:59‘ ORDER BY file.id DESC LIMIT 0,20

select * from gmvcsbase.base_file file,gmvcsbase.base_user user,gmvcsbase.base_department dep, gmvcsbase.base_workstation work,
(
select file.id
from gmvcsbase.base_file file,gmvcsbase.base_user user,gmvcsbase.base_department dep, gmvcsbase.base_workstation work
where file.police_id=user.police_id and user.dep_code=dep.code and file.workstation_sid=work.sid and file.capture_time>=‘2013-11-30‘
AND file.capture_time<=‘2014-03-19 23:59:59‘
ORDER BY file.import_time DESC LIMIT 0,20
) as t
where file.police_id=user.police_id and user.dep_code=dep.code and file.workstation_sid=work.sid and file.id=t.id
ORDER BY file.import_time DESC

关于优化sql查询的一个方法。,布布扣,bubuko.com

关于优化sql查询的一个方法。

上一篇:PowerDesigner 从现有的数据库表中反向生成数据模型


下一篇:SQL复制表