Can someone help me understand why the following query is not offsetting correctly?
It's meant to select all records in the games table, and add a column with a value of 0 or 1 based on whether a record in another table (wishlist) exists with the same gameId @memberId (in plain English, get me all records from games, and mark any game that exists in the wishlists table, under whatever memberId I give you)
SELECT *,
CASE WHEN wishlists.memberid IS NULL THEN 0 ELSE 1 END AS InMembersList
FROM games
INNER JOIN platforms ON games.platformid = platforms.id
LEFT OUTER JOIN wishlists ON games.id = wishlists.gameid and wishlists.memberid = @memberId
WHERE platforms.platformUrlId = @platformUrlId
ORDER BY releaseDate DESC
LIMIT 1,8
When I change the offset from 1 to 2, or 3, or whatever, many of the same records appear, which does not make any sense. Where am I going wrong?
Schema:
platforms(id, platform)
members(id, name)
games(id, platformId, releaseDate)
wishlists(id, memberId, gameId)