Back

Ruby on Rails null or nil querry

added on :: 1 October 2014


Design.where("business_name IS NULL || business_name = ''")

With PostgreSQL

Design.where("business_name IS NULL or CAST(business_name as text) = ''")

For nil values
 
Design.where(:business_name => '')

If you want to find items which are not null or empty

Design.where.not(:business_name => '')
Design.where.not("business_name IS NULL or CAST(business_name as text) = ''")

Address.where(["city != ?", "London"])




Back