• 记录之前工作用到费劲sql


    表为单独表,树结构 layer共有4层, 此sql为通过id list 查询出 layer = 2 的 id 个数

      id , parent_id, layer

    SELECT
      COUNT(DISTINCT ID) AS count
    FROM
    (
      SELECT
        DISTINCT parent_geography_id AS ID
      FROM
        core_master_db.geography
      WHERE
        (
          geography_id IN (49887, 49888, 49886, 1775, 1)
          OR
          geography_id IN

          (
            SELECT
              DISTINCT parent_geography_id
            FROM
              core_master_db.geography
            WHERE
              geography_id IN (49887, 49888, 49886, 1775, 1)
            AND

              layer = 4
          )
        )
      AND layer = 3
      UNION ALL
      SELECT
        DISTINCT geography_id AS ID
      FROM
        core_master_db.geography
      WHERE
        geography_id IN (49887, 49888, 49886, 1775, 1)
      AND
        layer = 2
    )   geography

  • 相关阅读:
    ihaiLjEUSx
    表达式的逆波兰式转化模板
    运算表达式求值模板
    程序员花式拜年脚本
    vbs脚本实现自动打字祝福&搞笑
    MFC实现红黑砖块
    vbs脚本实现qq定时发消息(初级)
    打包java程序生成exe
    webpack配置
    vue路由
  • 原文地址:https://www.cnblogs.com/lixuchun/p/8708008.html
Copyright © 2020-2023  润新知