关于优化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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。