necker
necker

Reputation: 7143

How to find elements that have some attribute NULL

I'd like to find rows in my table that have end_date NULL or not present.

I am not sure how to do this with PostgreSQL nor could I find any useful examples online. I am using Rails though.

I tried sth like:

   Tag.where("end_date IS ?", nil)

and also

 Tag.where("end_date IS NULL")

Without success. The above returns all the tags that exist which is wrong. Maybe I should do it sth like

 Tag.where("end_date IS NOT DATE")

I'd appreciate any answers!

Upvotes: 0

Views: 48

Answers (1)

Gergo Erdosi
Gergo Erdosi

Reputation: 42048

Use a hash in where():

Tag.where({ end_date: nil })

Upvotes: 1

Related Questions