# user_id 10000から20000 で、 photo が nullでない UserImageを検索
UserImage.where("photo is not null").where( :user_id => 10000..20000).first 100
# OR search
User.where("chat_id = ? or chat_id =?", "smith", "john")
# And search
User.where("chat_id = ? and chat_id =?", "smith", "john")
# Not
t = User.arel_table; User.where(t[:name].not_eq('taro')).all
# Order
User.order( "name asc") t = User.arel_table; User.order(t[:name].asc)
# Range
User.where( id: 1..10 )
# Include
# null
User.where( photo: nil )
# not null
User.where( "photo is not NULL" )