Multi-word query searching across columns

I’m trying to implement a basic name search on a People table with
separate first_name and last_name columns. I am using the
will_paginate plugin and have the following search method in the
model:

def self.search(search, page)
paginate :page => page,
:conditions => [“lower(last_name) like ? or
lower(first_name) like ?”, “%#{search.downcase}%”, “%#{search.downcase}
%”]
end

This works fine if the query entered is a single word like “Bob” - the
last_name field is queried for “Bob” and the first_name field is
queried for “Bob”.

However, if I enter a query like “Bob Dylan”, how would I find the
record(s) where first_name = “Bob” and last_name = “Dylan”? This seems
to be the opposite of “full text search”, unless I’m missing some of
what is possible with the full text search plugins.

I’m new at this - many thanks for any help.

Not tested but mine would look something like

:conditions => [“LOWER(CONCAT(first_name,’ ', last_name)) like ?”, “%
#{search.downcase}%”]

kates

Thanks - that is exactly what I needed. I obviously need to brush up
on my SQL.