zoukankan      html  css  js  c++  java
  • 关于优化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

    暗夜之中,才见繁星;危机之下,暗藏转机;事在人为,为者常成。
  • 相关阅读:
    HDU1263(map)
    Let the Balloon Rise HDU
    PAT甲级1007
    PAT乙级1041
    PAT乙级1037
    PAT乙级1031
    PAT乙级1025
    Hanoi(栈实现)
    《全球资产配置》读后感 读书笔记
    《与内心的恐惧对话》读后感 读书笔记
  • 原文地址:https://www.cnblogs.com/zenghansen/p/3611375.html
Copyright © 2011-2022 走看看