NSPredicate with SubQuery

◇◆丶佛笑我妖孽 提交于 2019-12-10 15:43:16

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!