分组后按2内连接排序

时间:2015-04-06 08:23:02

标签: mysql

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

我正在尝试执行查询,但它不会影响我的结果中的任何内容 在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

1 个答案:

答案 0 :(得分:1)

这是如何做到的:

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