5

LIKE query in mysql, queries the database and disregards case. For example:

"bzupnick" = "Bzupnick" #  false
"bzupnick" LIKE "Bzupnick" # true

So how does one do a LIKE query in Ruby on Rails.

Here's an example query:

@results = User.joins(:jobs).where(:jobs => { :job_name => job }, :users => { :zip => zip })
0

1 Answer 1

10

try this..

User.joins(:job).where("job_name like ? and name like ?","%Dummy%", "%Bzupnick")

You can also verfify the SQL query by putting to_sql at the end of the above statement

Sign up to request clarification or add additional context in comments.

1 Comment

So the "?"s and "%" thing didn't work, but using interpolation, it worked beautifully.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.