我有以下几点:
time_range = (1.month.ago.beginning_of_month..1.month.ago.end_of_month)
Comment.where(:created_at => time_range).count
我怎样才能在where子句中添加如下语句:
.where("user_id is not in (?)",[user_ids]).
如何将两者结合起来?谢谢
我有以下几点:
time_range = (1.month.ago.beginning_of_month..1.month.ago.end_of_month)
Comment.where(:created_at => time_range).count
我怎样才能在where子句中添加如下语句:
.where("user_id is not in (?)",[user_ids]).
如何将两者结合起来?谢谢
如果需要"AND"条件查询,请try 以下操作:
Comment.
where(:created_at => time_range).
where("user_id is not in (?)",[user_ids])
这将产生SQL,比如:select ... where ... AND ...
如果你想让WHERE子句更复杂,例如:where ( a AND b) OR (c AND d)
,你必须自己把条件组合到子句中,例如:.
Comment.where("(a AND b ) OR (c AND d)")