[英]where :thisyear > :last unless :last nil?
I have an sql search query in my rails app: 我的rails应用程序中有一个SQL搜索查询:
patients = patients.where("thisyear < last ") if search.present?
My problem is that this search query also disselects database entrys where the :last
is nil 我的问题是,此搜索查询还会取消选择:last
为nil的数据库条目
My question is how can i write an search query that does not get applied on patients where the column :last
is nil
? 我的问题是我该如何写一个搜索查询,该查询不能应用于列:last
为nil
患者? Thanks 谢谢
patients = patients.where("last IS NULL OR thisyear < last") if search.present?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.