0
I have the following query
select DISTINCT(p.id),g.id, p.slug, p.nome
from game g
join game_plataforma gp on g.id=gp.id_game
join plataformas p on gp.id_plataforma=p.id
group by g.id,p.id,p.slug, p.nome
order by g.id DESC
limit 5;
I’ve tried many ways but I can’t find the mistake.
I want to list the platforms in descending order by the posting date of the games. Already almost does it but I want to group or in case show different, so my list should be
xbox
play4
nintendo3ds
and only show these 3
I switched to
select DISTINCT(p.id), p.slug, p.nome
from game g
join game_plataforma gp on g.id=gp.id_game
join plataformas p on gp.id_plataforma=p.id
group by p.nome
order by g.id DESC
limit 5
and made this mistake
#1055 - Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'desapego.p.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
http://sqlfiddle.com/#! 9/e6520/4/0 no fidle works
group by g.id,p.id,p.slug, p.nome
? Why?– Jéf Bueno
Do the GROUP only by name, and order by MIN( campodadata ) if it is by the oldest post, or MAX( campodadata ) if it is by the newest post. - This query of yours seems a little "rolled up" for the purpose. Play some sample data on http://SQLFiddle.com with the actual table structure and enough test items, which we can solve faster.
– Bacco
I’ll put it there
– Jasar Orion
http://sqlfiddle.com/#! 9/e6520/4/0 no fiddle worked like this on my mysql gave this error I posted above
– Jasar Orion
@Jasarorion needs to see if there are any engine or version differences. And see if you can take the distinct as well. The logic is more or less what I commented, but the specifics you need to test there, it is complicated to know what is happening (even more than in fiddle worked).
– Bacco
I am using mysql 5.7
– Jasar Orion