我想返回一个数组,其中包含名为 bookings
的表中的所有行其中列 returned_date
是空的。
到目前为止,我已经尝试了 Booking.where("returned_date <> ''")
,它选择了所有存在 returned_date 的记录,但我想要一个反向选择。
最佳答案
如果你想得到 returned_date
列是 null
:
Booking.where(returned_date: nil)
关于ruby - Rails - 如何使用 where() 查找特定列值为 nil 的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24361934/