hi, I tried to find the not null elements from database @genus_counts = Table.count(:all, :conditions=> {:col1 => params[:gm], :col2 => nil}, :without => {:col3 => nil}) its not recognising "without" function. and @genus_counts = Table.count(:all, :conditions=> {:col1 => params[:gm], :col3 != nil :col2 => nil}) its not recognising "!=" operator.... Kindly suggest me and correct above statement. -- With Regards Palani Kannan. K -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Dear All, @genus_count = Table.count(:all, :conditions => [''col3 is not null and col2 is null and col1 = ?'', params[:gm]) <%= @genus_count %> It works. -- With Regards, Palani Kannan. K, -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On which database(s)? This is something I have wrestled with before on SQLite deploying to MySQL. What works on one fails on the other, and vice-versa. Walter On Oct 15, 2010, at 10:46 AM, PalaniKannan K wrote:> Dear All, > > @genus_count = Table.count(:all, :conditions => [''col3 is not null > and col2 is null and col1 = ?'', params[:gm]) > > > <%= @genus_count %> > > > It works. > > > > -- > With Regards, > > Palani Kannan. K, > > > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails- > talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > .-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
PalaniKannan K wrote in post #950423:> I tried to find the not null elements from database > > @genus_counts = Table.count(:all, :conditions=> {:col1 => params[:gm], > :col2 > => nil}, :without => {:col3 => nil})In SQL you don''t use equality to find NULL values. SELECT * FROM my_table WHERE my_col IS NULL; or SELECT * FROM my_table WHERE my_col IS NOT NULL; Rails: :conditions => [ "col1 = ? and col2 IS NULL and col3 IS NOT NULL", params[:gm] ] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Walter Davis wrote in post #954658:> On which database(s)? This is something I have wrestled with before on > SQLite deploying to MySQL. What works on one fails on the other, and > vice-versa.AFAIK this syntax work fine in both SQLite and MySQL and every other database backend I''ve used. I believe it is compliant with SQL ''92 standard. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.