Ruby on rails 如何获取列不是0的记录
我正在尝试添加范围,其中Ruby on rails 如何获取列不是0的记录,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我正在尝试添加范围,其中sign\u in\u count列中的所有记录都不是0 我该怎么办 scope :confirmed, where("sign_in_count" => 0) scope :confirmed, where("sign_in_count <> 0 ") 这可能会获取sign\u in\u count为0的所有记录 我想要相反的。我该怎么做?范围:已确认,在哪里(“在计数0中签名”) scope :confirmed, where("sign_in_
sign\u in\u count
列中的所有记录都不是0
我该怎么办
scope :confirmed, where("sign_in_count" => 0)
scope :confirmed, where("sign_in_count <> 0 ")
这可能会获取sign\u in\u count
为0的所有记录
我想要相反的。我该怎么做?范围:已确认,在哪里(“在计数0中签名”)
scope :confirmed, where("sign_in_count" => 0)
scope :confirmed, where("sign_in_count <> 0 ")
哪个更好?您的或范围:已确认,其中(“在计数中签名!=?”,0)
@HUSTEN”是SQL-92标准。所以可能比“!=”更便于携带。此外,“0”不会返回符号为空的行。所以请记住这一点。这取决于您使用的数据库。而且imho NULL值也可能导致问题,我会选择“>0”作为保证谢谢大家!!很高兴知道