问题
I have this relationship:
player <—>> games <<—> quiz
and want to get all quiz not in a game of a player, like
SELECT *
FROM ZQUIZ
WHERE Z_PK NOT IN (SELECT ZQUIZ
FROM ZGAME
WHERE ZPLAYER == 1)
Can anybody help?
回答1:
This can be done with a SUBQUERY clause. If myPlayer
is the player in question:
let predicate = NSPredicate(format:"SUBQUERY(games,$g, $g.player == %@).@count == 0", myPlayer)
来源:https://stackoverflow.com/questions/35688892/nspredicate-with-subquery