以下查询需要更改哪些内容?我希望所有那些date_of_leaving为null或date_of_leaving在过去60天之间或date_of_leaving大于或等于Date.today或当前日期的员工。
employees = @company.employees.where('date_of_leaving BETWEEN ? AND ? OR date_of_leaving IS NULL OR date_of_leaving IS >= Date.today', Date.today - 60, Date.today)
我尝试了另外一种方式,如下所示。
employees = Company.find(4).employees.where('date_of_leaving BETWEEN ? AND ? OR date_of_leaving IS NULL OR date_of_leaving IS >= ?', Date.today - 60, Date.today,Date.today)
答案 0 :(得分:1)
我认为您的问题是短语IS >=
。
您不应该将is
与比较运算符一起使用。只是运营商。取出它,否则看起来不错。