A
A
Abra Kadabra2017-07-25 22:56:30
PHP
Abra Kadabra, 2017-07-25 22:56:30

How to get 2 rows that match 1 ID?

There is a table:
id, name, gameID, scores
gameID - unique for every two players.
Is it possible to get the first 100 pairs of players (with the highest scores) with a single request?
Is it better to do multiple requests?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AStek, 2017-07-26
@Jmaster

SELECT t1.*, t2.*, (t1.scores+t2.scores) as score_sum FROM talbe t1
JOIN table t2 ON t1.gameID = t2.gameID AND t2.id <> t1.id
ORDER BY score_sum DESC
LIMIT 100
as something so...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question