Find active record condition of not equal

Hi,

I have tried creating a not equal condition in the find statment but it just outputs an empty array.

model.find(:first, :conditions => [" id = ? AND market = ? AND promotion <> ? " , id , name, "y"],:order => 'id desc').price

I have tried != instead of <>

I have tried googling for the answer but i can't seem to find it. What do i need to put to give a not equal condition?

Database is mysql.

Still unsolved. However != seems to work for integers but not strings.

Still unsolved. However != seems to work for integers but not strings.

!= is what you want (except if you testing whether something is not NULL, if you want your query to also return rows where promotion is NULL then you will need to change your query). Is promotion a boolean attribute? If so then you should put ["foo != ?", true] and let activerecord handle the mapping of true/false to whatever value is stored in the database.

Fred

Thanks fred for your reply I managed to solve it, it was because some of my values in the column were nil so it affected the find statement.