AI智能
改变未来

mysql使用findbyset关联查询时数据去重

先mark一下。之后整理

SELECT a.id, a.type, a.name, a.config_rule_ids AS configRuleIds, a.range_ids AS rangeIds, a.allocation_ids AS allocationIds, a.check_policy AS checkPolicy, a.check_expire1 AS checkExpire1, a.appeal_expire1 AS appealExpire1, a.check_expire2 AS checkExpire2, a.check_expire2_default AS checkExpire2Default, a.check_expire3 AS checkExpire3, a.check_expire3_default AS checkExpire3Default, a.first_run_time AS firstRunTime, a.period, a.next_run_time AS nextRunTime, a.status, a.creator, a.create_time AS createTime, a.updater, a.update_time AS updateTime, a.remark,CONCAT(a.config_rule_ids,\"--\",GROUP_CONCAT(DISTINCT b.name))configRuleNames,CONCAT(a.range_ids,\"--\",GROUP_CONCAT(DISTINCT c.name))rangeNames, CONCAT(a.allocation_ids,\"--\",GROUP_CONCAT(DISTINCT d.allocation_name))allocationNames FROM ai_task a LEFT JOIN config_rule b ON FIND_IN_SET(b.id,a.config_rule_ids) LEFT JOIN config_range c ON FIND_IN_SET(c.id,a.range_ids) LEFT JOIN inspect_allocation d ON FIND_IN_SET(d.id,a.allocation_ids) WHERE 1=1 GROUP BY a.id DESC LIMIT 10;
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » mysql使用findbyset关联查询时数据去重