11175
(-- --)
1
paginate :per_page => 15, :page => page,
:conditions => ['tags like ?', "%#{search}%"], :order => 'created_at
DESC'
Hi, just wondering how I would change the conditions to include an extra
like?
I want to do:
'tags AND body like ?'
Not sure what's the proper syntax for this,
Thanks!
That part is straight SQL (with some nice substitutions) so you'd want:
:conditions => ['tags LIKE ? AND body LIKE ?', "%#{search}%", "%#{search}%"]
that will return results where both tag and body are like your search.
-philip
11175
(-- --)
3
Super, thanks! Is there such an operator as OR?
Thanks!
Super, thanks! Is there such an operator as OR?
Yep. OR 
No idea what your level of SQL knowledge is and I don't mean to give offense, but you may find this helpful:
-philip
11175
(-- --)
5
Philip Hallstrom wrote:
Super, thanks! Is there such an operator as OR?
Yep. OR 
No idea what your level of SQL knowledge is and I don't mean to give
offense, but you may find this helpful:
SQL Tutorial
-philip
Ha ha, thanks Philip. I've read that article before. The problem is, I
haven't worked very much with SQL at all before. =) Thanks!