I learned that using field in (a1,a2,a3) is comparably faster than using = operator.
SELECT *
FROM user
WHERE Greeting IN ('hello', 'hi', 'hey')
How can I write above query in rails way?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’d do something like this:
Rails will know what to do with an array,
%w{hello hi hey}, as a value for a placeholder. Or, if you already had an array of strings:or, probably the most Railsy way, like this: