MYSQL 视图数据 去重问题

baidu_33376091 2015-12-14 08:38:06
select
`cp`.`CANDIDATE_PUSH_ID` AS `CANDIDATE_PUSH_ID`,
`hc`.`NAME` AS `NAME`,`hs`.`SUPPLIER_ID` AS `SUPPLIER_ID`,
`hs`.`SUPPLIER_NAME` AS `SUPPLIER_NAME`,
`hd`.`DEMAND_ID` AS `DEMAND_ID`,
`hd`.`DEMAND_NAME` AS `DEMAND_NAME`,
(case `cp`.`SCREEN_IS_RECOMMEND` when 0 then '推荐' when 1 then '不推荐' end) AS `SCREEN_RESULT`,
`cp`.`ACTUAL_INTERVIEW_TM` AS `ACTUAL_INTERVIEW_TM`,
`cp`.`PRE_INTERVIEW_DES` AS `PRE_INTERVIEW_DES`,
`cp`.`FILTER_FAILED_REASON` AS `FILTER_FAILED_REASON`,
(case `cp`.`STATUS` when 1 then '待筛选' when 2 then '已邀约' when 3 then '经理待面试' when 4 then '待HR面试' when 5 then '待确认入司时间' when 11 then '筛选不通过' when 12 then 'IT面试不通过' when 13 then 'HR不通过' when 14 then '放弃入场' end) AS `STATUS_NAME`,
`cp`.`STATUS` AS `STATUS_ID`,
date_format(`cp`.`PUSH_TM`,'%Y-%m-%d') AS `PUSH_TM`
,date_format(`cp`.`PRE_INTERVIE_TM`,'%Y-%m-%d') AS `PRE_INTERVIE_TM`
from ((((`tt_hos_candidate_push` `cp`
left join `tt_hos_demand` `hd` on((`hd`.`DEMAND_ID` = `cp`.`DEMAND_ID`)))
left join `tt_hos_candidate_push` `hcp` on((`hcp`.`DEMAND_ID` = `cp`.`DEMAND_ID`)))
left join `tt_hos_candidate` `hc` on((`hc`.`CANDIDATE_ID` = `hcp`.`CANDIDATE_ID`)))
left join `tt_hos_supplier` `hs` on((`hs`.`SUPPLIER_ID` = `hc`.`SUPPLIER_ID`)))

怎么根据CANDIDATE_PUSH_ID 这个字段去重呢 现在 没条数据都有五条或者更多。直接用DISTINCT 没有用
...全文
303 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
你别这么关联,你要这样: select from tb left join ( select distinct abc from xx where xx.id = tb.id )t1 ( select distinct abc from xx where xx.id = tb.id )t2 先去重,然后再关联,而不是先关联再去重
回复
中国风 2015-12-14
在tt_hos_candidate_push表CANDIDATE_PUSH_ID相同的有没有多条记录? 如果没用应该在 左联的表中有一对多的表,才会产生重复数据 要解决首先要找出是那个表为一对多 这样一个个表检查
 select DEMAND_ID from tt_hos_demand group by DEMAND_ID having count(*)>1
处理GROUP BY
回复
中国风 2015-12-14
把一对多的关联表,用GROUP BY 处理
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2015-12-14 08:38
社区公告
暂无公告