Welcome Guest | Login

mysql search with ?

Hey where in a mysql search do i put ? so that apples in applesauce if found?

@businesses = Business.find(:all, :conditions => ['name LIKE ?
                                                     or description LIKE ?',
                                                     "%#{params[:search]}%",
                                                     "%#{params[:search]}%"], :order => 'name')

i tried %?params% but no luck.

Right now it just finds apples instead of apples from applesauce

2008-07-21 09:24 PM

This one is a bit tricky - it needs to be:

@search = params[:search]
@businesses = Business.find(:all, :conditions => ['name LIKE ? or description LIKE ?', "%" + @search + "%","%" + @search + "%"], :order => 'name')

 

2008-07-22 12:17 AM

thanks William

2008-07-22 12:19 AM


Hello Guest! In order to post you must be an active client with us, please log in or sign up today!