0

What does the "%#{}%" more specifically the %. I know that "#{variable}" is simply string interpolation, but what about the%`?

I am implementing a simple search form similar to Rails 4 LIKE query - ActiveRecord adds quotes.

Does it have to do with ActiveRecord or the database?

1 Answer 1

3

% is a wild card for SQL that represent any characters. So if you need to find anything that includes blahblah for instance, you search for %blahblah%.

2
  • Could you say it is similar to Regex in pattern matching?
    – Patrick
    Mar 16, 2014 at 7:06
  • If you omit both percent signs, SQL will try to make an exact match. You can use "blahblah%" to effect a "starts with" match, and "%blahblah" to effect "ends with."
    – Jake Vose
    Oct 6, 2014 at 13:21

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.