I have 3 tables
A users table (userID, userName)
A leaderboard table (userID, score)
A friends table (userIDA, userIDB)
I would like to produce the following result:
userName, score, userIDA
Dave, 100, 1
Simon, 200, 5
Paul, 300, NULL
The 3rd record is NULL as there is no record in "friends" with a userIDB
matching users (or leaderboard) userID
I have tried this:
SELECT users.username, gameLeaderboards.playerpoints, friends.userA
FROM gameLeaderboards
JOIN users ON gameLeaderboards.userID = users.ID
LEFT JOIN friends ON gameLeaderboards.userID = friends.userB
WHERE friends.userA = 79760
The where is so there is only a value in the "userIDA" column if the
user is friends with userID 79760
But what I get instead of lots of records with 79760 and NULLs is just
records from the leaderboard table that have a matching userID in the
friend table, hmmf
Any ideas?
Thanks
-
Dave
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]