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 没有用
...全文
548 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
LongRui888 2015-12-17
  • 打赏
  • 举报
回复
你别这么关联,你要这样: 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 处理

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧