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.
on 2008-12-07 10:11
on 2008-12-07 10:21
Helping tyliong in #rubyonrails irc channel ----- Ryan B. Freelancer http://frozenplague.net
on 2008-12-07 11:18
Still unsolved. However != seems to work for integers but not strings.
on 2008-12-07 11:52
On Dec 7, 9:28 am, "Tan YL" <email@example.com> wrote: > 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
on 2008-12-07 11:56
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.