-1

Both of the following tables have 2 entries for the same player.

Table punishment : table punishment Table cooldown : table cooldown

SELECT punishment_id, punishment.reason, cooldown.id, cooldown.time_left FROM player INNER JOIN punishment ON player.most_uuid=punishment.most_uuid INNER JOIN cooldown ON player.most_uuid=cooldown.most_uuid WHERE player.most_uuid=2941535451391147758

In the result of this query I have some kind of "duplicated" rows. I get 4 rows when I'd like to have just 2 with the essentials values inside.

Result from the queryresult of the query

I need all the values present in the rows, but as you can see there are pairs of rows with the exact same value twice.

Is there a possibility of merging them to actually have 2 like this (and not having duplicated values):

enter image description here

1

I think :

SELECT punishment_id, punishment.reason, cooldown.id, cooldown.time_left FROM player INNER JOIN punishment ON player.most_uuid=punishment.most_uuid INNER JOIN cooldown ON player.most_uuid=cooldown.most_uuid WHERE player.most_uuid=294153545139114775

Can be transform in :

SELECT punishment_id, punishment.reason, cooldown.id, cooldown.time_left FROM punishment INNER JOIN cooldown ON punishment.most_uuid=cooldown.most_uuid WHERE punishment.most_uuid=294153545139114775

This only work if you don't want to check existence on player table.

If you did it on purpose, I recommend using GROUP BY :

SELECT punishment_id, punishment.reason, cooldown.id, cooldown.time_left FROM player INNER JOIN punishment ON player.most_uuid=punishment.most_uuid INNER JOIN cooldown ON player.most_uuid=cooldown.most_uuid WHERE player.most_uuid=294153545139114775 GROUP BY punishment_id

I hope this is usefull. Bye

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.