在mysql中使用LEFT JOIN中的DISTINCT

时间:2017-03-28 06:46:11

标签: mysql left-join

这是我的查询

SELECT agent.agtname AS `agent_name`, agent.id as `agent_id`, applicant.* 
FROM `applicant` 
LEFT JOIN agent ON agent.id = applicant.agtid 
WHERE agent.branchid ='".$branch_id."' 
AND applicant.appt_status LIKE '%SENT%' 
AND DATE(`modifiedon`) = CURDATE()

我不需要重复的agent_name以及agent_id ..

提前致谢

1 个答案:

答案 0 :(得分:1)

让我们试试吧。 它会起作用......

SELECT agent.agtname as agent_name,agent.id as agent_id, applicant.* FROM applicant LEFT JOIN agent ON agent.id = applicant.agtid WHERE agent.branchid ='".$branch_id."' AND applicant.appt_status LIKE '%SENT%' AND DATE(modifiedon) = CURDATE() GROUP BY agent.agtname