简体   繁体   English

哪里:thisyear>:last除非:last nil?

[英]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 ? 我的问题是我该如何写一个搜索查询,该查询不能应用于列:lastnil患者? Thanks 谢谢

patients = patients.where("last IS NULL OR thisyear < last") if search.present?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM