A-10C Warthog Serial Number. Just click and download. New download - 90 days free serial numberQ:
Can't figure out this SQL query
Basically I have this query:
SELECT *
FROM users AS users, user_competition AS competition, user_badge AS badge,
user_score AS score
WHERE users.id = competition.user_id
AND competition.id = badge.competition_id
AND badge.id = score.badge_id;
This query returns all the records for the users of the database, but the results of this query will be duplicated and I want to avoid this.
And I tried changing it to:
SELECT *
FROM users AS users, user_competition AS competition, user_badge AS badge,
user_score AS score
WHERE users.id = competition.user_id
AND competition.id = badge.competition_id
AND badge.id = score.badge_id;
GROUP BY competition.user_id;
But this query also returns duplicated results.
I would like to ask for any suggestions? Thanks in advance.
A:
Put all the tables in a subquery
SELECT u.id,
score.user_id,
score.badge_id,
score.score
score.current,
score.next,
score.after
FROM (
SELECT *
FROM users
INNER JOIN user_competition ON users.id = user_competition.user_id
INNER JOIN user_badge ON user_competition.id = user_badge.competition_id
INNER JOIN ac619d1d87
Related links:
Comentarios