weixin_43078650 2020-04-22 22:38 采纳率: 0%
浏览 150
已结题

请大佬帮忙看看这段sql语法上面能怎么优化一下

请大佬帮忙看看这段sql语法上面能怎么优化一下

select...
from 表 A a,表B b,表C c
 where c.waree_id = #{wareId}
    and a.ware_id = #{wareId}
    and b.warehouse_id = #{wareId}
    and c.id = a.inventory_id
    and a.id = b.detail_id
    and a.gmt_modified between #{adjustrStart} and #{adjustEnd}
    and a.status = 2
    and c.adjust_describe = #{adjustDescribe}
    <if test="itemCode != null">
      and a.item_code = #{itemCode}
    </if>
    <if test="deptCode != null">
      and c.dept_code = #{deptCode}
    </if>
    <if test="deptCodes != null and deptCodes.size > 0">
      and c.dept_code in
      <foreach item="iDeptCode" collection="deptCodes" open="(" separator="," close=")">
        #{iDeptCode}
      </foreach>
    </if>
    <if test="serialNo != null">
      and b.serial_no = #{serialNo}
    </if>
    <if test="reasonCode != null">
      and c.detail_reason = #{reasonCode}
    </if>

    and a.id = b.detail_id
    group by b.serial_no order by b.last_print_date desc
  • 写回答

2条回答 默认 最新

  • dabocaiqq 2020-04-23 00:01
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 使用STM32F103C6微控制器设计两个从0到F计数的一位数计数器(数字),同时,有一个控制按钮,可以选择哪个计数器工作:需要两个七段显示器和一个按钮。
  • ¥15 在yolo1到yolo11网络模型中,具体有哪些模型可以用作图像分类?
  • ¥15 AD9910输出波形向上偏移,波谷不为0V
  • ¥15 淘宝自动下单XPath自动点击插件无法点击特定<span>元素,如何解决?
  • ¥15 曙光1620-g30服务器安装硬盘后 看不到硬盘
  • ¥15 抖音直播广场scheme
  • ¥15 为什么我明明有这个文件调试器还显示错误?
  • ¥15 软件工程用例图的建立(相关搜索:软件工程用例图|画图)
  • ¥15 如何在arcgis中导出拓扑关系表
  • ¥15 处理数据集文本挖掘代码