I'm trying to find some items that contain a certain string. If I do:
MyModel.where("description LIKE ?",keyword)
it will generate a query for an exact match. I would like to make it generate a LIKE %keyword%
query. How can I do that?
like_keyword = "%#{keyword}%"
MyModel.where("description LIKE ?", like_keyword)
MyModel.where("description LIKE (?)", "%#{keyword}%")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With