簡體   English   中英

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

[英]where :thisyear > :last unless :last nil?

我的rails應用程序中有一個SQL搜索查詢:

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

我的問題是,此搜索查詢還會取消選擇:last為nil的數據庫條目

我的問題是我該如何寫一個搜索查詢,該查詢不能應用於列:lastnil患者? 謝謝

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