gpt4 book ai didi

mysql - Order by after group by in 2 innerjoin

转载 作者:行者123 更新时间:2023-11-29 00:01:45 24 4
gpt4 key购买 nike

我有一个显示错误的问题。

我正在尝试执行查询,但它不会影响我的结果在 MySQL 中。

我做错了什么?

SELECT
dominio.id as dominio_id,palavras.id AS palavras_id,
palavras.palavra as palavras_palavra,rank_monitor.dominio as
rank_dominio,dominio.dominio AS dominio_dominio,
rank_monitor.palavras as rank_palavras,dominio.id as
id_dominio,rank_monitor.posicao_google as google,
rank_monitor.verificado as verificao_robo

FROM rank_monitor

INNER JOIN dominio ON rank_monitor.dominio=dominio.id
INNER JOIN palavras ON rank_monitor.palavras=palavras.id where dominio.id = 1
GROUP BY rank_monitor.palavras
order BY rank_monitor.verificado DESC

最佳答案

这是可以做到的:

select
d.id as dominio_id,
p.id AS palavras_id,
p.palavra as palavras_palavra,
rm.dominio as rank_dominio,
d.dominio as dominio_dominio,
rm.palavras as rank_palavras,
d.id as id_dominio,
rm.posicao_google as google,
rm.verificado as verificao_robo
from rank_monitor rm
join dominio d on d.id = rm.dominio
join palavras p on p.id = rm.palavras
left join rank_monitor rm1 on rm1.dominio = rm.dominio and rm1.palavras = rm.palavras
and rm1.verificado > rm.verificado
where
rm1.id is null
and
d.id = 1
group by rm.palavras

关于mysql - Order by after group by in 2 innerjoin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29467759/

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