Hello! I need some help. I am doing an auto complete that hast to find result from a mysql database of some people if the text written in the text box matches the name or last name. It works if i only want to find matches with the name or indepently the secon name but not with a or of both. I have this @inscritos = Inscrito.find(:all, :conditions => ["LOWER(nombre) LIKE ?", ''%'' + params[:familiar]["0"].downcase + ''%'' ], :order => ''apellido ASC'', :limit => 8) this works fine but then i want something like this @inscritos = Inscrito.find(:all, :conditions => ["LOWER(nombre) OR LOWER(apellido) LIKE ?", ''%'' + params[:familiar]["0"].downcase + ''%'' ], :order => ''apellido ASC'', :limit => 8) -- Felipe Vergara Contesse IngenierĂa Civil Industrial UC --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Shouldn''t it be @inscritos = Inscrito.find(:all, :conditions => ["LOWER(nombre) LIKE ? OR LOWER(apellido) LIKE ?", ''%'' + params[:familiar]["0"].downcase + ''%'' ], ''%'' + params[:familiar]["0"].downcase + ''%'' ], :order => ''apellido ASC'', :limit => 8) otherwise you are saying ''LOWER(nombre) is true or LOWER(apellido) LIKE blah'' Cheers Simon On Fri, 02 Jan 2009 08:12:32 +0900, Felipe Vergara <felvergara-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello! > > I need some help. I am doing an auto complete that hast to find result > from > a mysql database of some people if the text written in the text box > matches > the name or last name. It works if i only want to find matches with the > name > or indepently the secon name but not with a or of both. > I have this > > @inscritos = Inscrito.find(:all, > :conditions => ["LOWER(nombre) LIKE ?", > ''%'' + params[:familiar]["0"].downcase + ''%'' ], > :order => ''apellido ASC'', > :limit => 8) > > this works fine but then i want something like this > > @inscritos = Inscrito.find(:all, > :conditions => ["LOWER(nombre) OR LOWER(apellido) LIKE ?", > ''%'' + params[:familiar]["0"].downcase + ''%'' ], > :order => ''apellido ASC'', > :limit => 8)--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
On Thu, Jan 1, 2009 at 3:12 PM, Felipe Vergara <felvergara-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I need some help. I am doing an auto complete that hast to find result from > a mysql database of some people if the text written in the text box matches > the name or last name. It works if i only want to find matches with the name > or indepently the secon name but not with a or of both.> @inscritos = Inscrito.find(:all, > :conditions => ["LOWER(nombre) OR LOWER(apellido) LIKE ?",I would think that would work if you enclosed your arguments in parens, e.g. (LOWER(nombre) OR LOWER(apellido)) LIKE ? or alternatively LOWER(nombre) LIKE ? OR LOWER(apellido) LIKE ? FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
I made a concatenation of nombre apellido and then made the search that worked great. Thank for your help -- Felipe Vergara Contesse IngenierĂa Civil Industrial UC --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---