gpt4 book ai didi

ruby-on-rails - rails 3 : How to get all Posts which ids are not in a given list?

转载 作者:行者123 更新时间:2023-12-03 00:47:58 25 4
gpt4 key购买 nike

要获取 publisher_id 等于 10、16 或 17 的所有帖子,我这样做:

Post.where(:publisher_id => [10, 16, 17])

如何获取 publisher_id 不等于 为 10、16 或 17 的所有帖子(即除了这三个 ID 之外的所有可能的 ID)?

最佳答案

只需执行:

Post.where(["publisher_id NOT IN (?)", [10, 16, 17]])

关于ruby-on-rails - rails 3 : How to get all Posts which ids are not in a given list?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6067327/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com