Answer the question
In order to leave comments, you need to log in
How to correctly compose a query with multiple Select and Limit in one query?
OK. I'll rephrase the question completely.
I have a growing database and an sql query to it, which should display all records from different tables, but it should recalculate several records in one table with a limit, but, at the same time, the result of the entire query should be with a different limit.
the query itself is:
SELECT
playerId,
matches,
x.kills,
x.match_id,
x.player_name,
x.steam_id_64
FROM
hlstats_PlayerUniqueIds
JOIN (
SELECT
count(steam_id_64) as matches,
sum(kills) as kills,
match_id,
player_name,
steam_id_64
FROM
match_player_stats
GROUP by
steam_id_64
ORDER by
id DESC
) x ON steam_id_64 = CAST(LEFT(hlstats_PlayerUniqueIds.uniqueId,1) AS unsigned) + CAST('76561197960265728' AS unsigned) + CAST(MID(hlstats_PlayerUniqueIds.uniqueId, 3,10)*2 AS unsigned)
GROUP by
uniqueId
ORDER by
matches DESC
LIMIT
0, 30
Answer the question
In order to leave comments, you need to log in
If you need for the last 10 days, then you need to add the necessary WHERE condition to the subquery. LIMIT simply limits the output of a query. Form a request in parts, then put everything together.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question