# Like clause for find

**URL:** <https://www.ruby-forum.com/t/like-clause-for-find/53204>\
**Category:** Rails\
**Created:** [January 29, 2006, 12:07am UTC](https://www.ruby-forum.com/t/like-clause-for-find/53204 "2006-01-29T00:07:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parker\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eada6e/32.png) [@Parker\_T](https://www.ruby-forum.com/u/Parker_T)\
**Post date:** [January 29, 2006, 12:07am UTC](https://www.ruby-forum.com/t/like-clause-for-find/53204/1 "2006-01-29T00:07:08Z")

</div>

I’ve done a bit of searching, but got too much noise and no  
perceivable signal. So, I apologize if I’m just missing this in the  
docs, seems like it should be easy.

I’d like to provide some basic search functionality in my app by  
allowing the user to enter in some text and generating a query like  
so:

SELECT \* FROM things WHERE field LIKE ‘%input’%;

If I want to do this am I stuck with find\_by\_sql, or is there a way to  
do this with a :conditions option?

Thanks,

## pt.

Parker T.  
[http://www.parkert.com/](http://www.parkert.com/)  
510.541.0125

---

<div class="post-metadata">

**Author:** ![Parker\_T](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eada6e/32.png) [@Parker\_T](https://www.ruby-forum.com/u/Parker_T)\
**Post date:** [January 29, 2006, 12:31am UTC](https://www.ruby-forum.com/t/like-clause-for-find/53204/2 "2006-01-29T00:31:16Z")

</div>

Parker T. wrote:

> If I want to do this am I stuck with find\_by\_sql, or is there a way to  
> do this with a :conditions option?

You can use conditions:

Thing.find(:all, :conditions =\> [‘field LIKE ?’, ‘%input%’])

Phil

–  
Philip R.  
[http://tzinfo.rubyforge.org/](http://tzinfo.rubyforge.org/) – DST-aware timezone library for Ruby
