开发者

Search accorss multiple columns?

开发者 https://www.devze.com 2023-03-26 21:07 出处:网络
I followed a railcast to search a single column from a database, which worked fine. Im trying to tweak it to search across multiple columns (first_name AND last_name), but its only searching across la

I followed a railcast to search a single column from a database, which worked fine. Im trying to tweak it to search across multiple columns (first_name AND last_name), but its only searching across last_name , im new to rails, so i feel like i have a simply syntax error (does || or?) Any s开发者_StackOverflow社区uggestions? Here's my code.

 where('first_name || last_name LIKE ?', "%#{search}%")


where('first_name LIKE ? || last_name LIKE ?', "%#{search}%" , "%#{search}%")
0

精彩评论

暂无评论...
验证码 换一张
取 消