gpt4 book ai didi

mysql - 与右表中的 where 进行左连接

转载 作者:行者123 更新时间:2023-11-29 12:03:58 25 4
gpt4 key购买 nike

我有这个连接:表 mmp_user 151 位用户表 MMP_MMPUBLISH_LOG URL 的访问

    select user.name as 'Usuário',count(log.referer) as 'Número de Acessos'
from mmp_user user
left JOIN MMP_MMPUBLISH_LOG log on (user.id=log.user_id)
where log.event_date between '2015-08-01' and '2015-08-08'
group by user.id
order by count(log.referer) desc

预期结果:151 行获得的结果:11行

请帮帮我

最佳答案

试试这个

SELECT u.name as 'Usuário',count(log.referer) as 'Número de Acessos'
FROM mmp_user u
LEFT JOIN (
SELECT user_id, referer
FROM MMP_MMPUBLISH_LOG
WHERE event_date BETWEEN '2015-08-01' AND '2015-08-08'
) log ON u.id=log.user_id
group by u.id
order by count(log.referer) desc

ps。下次不要使用“用户”,不清楚

关于mysql - 与右表中的 where 进行左连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31882905/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com