I'm trying to make a inner-join, but I can get it to work. This is my sql query
SELECT highscore.score, bruger.brugerNavn FROM highscore INNER JOIN bruger ON highscore.brugerID ON bruger.brugerID ORDER BY score DESC
I end up with this error
SELECT highscore.score, bruger.brugerNavn FROM highscore INNER JOIN bruger ON highscore.brugerID ON bruger.brugerID LIMIT 0, 25
#1064 - There is an error in the SQL syntax near 'ON bruger.brugerID LIMIT 0, 25' at line 1
I would appreciate any help:)
CodePudding user response:
Try this first:
SELECT h.score, b.brugerNavn
FROM highscore as h
JOIN bruger as b ON h.brugerID = b.brugerID
I usually add aliases for easier handling.
CodePudding user response:
SELECT highscore.score, bruger.brugerNavn
FROM highscore
INNER JOIN bruger ON highscore.brugerID = bruger.brugerID
ORDER BY score DESC
CodePudding user response:
You also try like that
SELECT highscore.score, bruger.brugerNavn
FROM Highscore as highscore
INNER JOIN Bruger as burger ON highscore.brugerID = bruger.brugerID
ORDER BY highscore.score desc
CodePudding user response:
You need to replace HS.brugerID on BG.brugerID
with HS.brugerID = BG.brugerID
under inner join
SELECT HS.score, BG.brugerNavn
FROM highscore as HS
INNER JOIN bruger as BG ON HS.brugerID = BG.brugerID
ORDER BY highscore.score DESC