zoukankan      html  css  js  c++  java
  • 一对多关联查询,只选择匹配的多条数据中的一条数据记录

    select b.PRODUCT_NAME,b.org_name,b.pic_url from (select bp.PLAN_PRODUCT,so.org_name,bp.ORGANIZATION_ID,bpi.PRODUCT_NAME,bpt.pic_url
    from QR_CODE t
    LEFT JOIN BIZ_PRODUCTIONPLAN bp on t.PARENT_ID=bp.PLAN_ID
    LEFT JOIN BIZ_PRODUCTINFO bpi on bp.PLAN_PRODUCT=bpi.PRODUCT_ID
    LEFT JOIN SYS_ORGANIZATION so on so.ORG_ID=bp.ORGANIZATION_ID
    RIGHT JOIN SYS_ENTERPRISE se on se.ENTERPRISE_ID=so.ENTERPRISE_ID
    LEFT JOIN (select b.glmk_id,min(b.pic_url) pic_url from BIZ_PICTURE b group by b.glmk_id ) bpt on bpt.glmk_id=bpi.product_id
    where t.QR_CODE_NUM like '%bz%' and t.DEL_FLAG=1 and bpi.product_name is not null
    and se.ENTERPRISE_COUNTRY=(select codeid from SYS_AREA where NAME='金水区')) b group by b.product_name,b.org_name,b.pic_url

    使用max()或min()函数取字段内数据最长的一个或最短的一个

  • 相关阅读:
    蒟蒻的填坑计划
    现在的状态....
    date modify
    set source
    image source
    simple auth
    net
    bridge
    iptable
    namespace
  • 原文地址:https://www.cnblogs.com/ysgcs/p/8530015.html
Copyright © 2011-2022 走看看