On Mar 1, 5:26 am, LeonS <[email protected]> wrote:
> Hi,
>
> I want to generate a query with conditions like that
>
> :conditions => ["score_team_1 ? score_team_2", compare_sign] .
>
> The resulting query ends e.g. with       score_team_1 '=' score_team_2
> How can i remove the apostrophes from include into the string?

You could also consider switching the way the condition is defined:

score_team_1 < score_team_2

is equivalent to:

score_team_1 - score_team_2 < 0

which (on MySQL - check your DB for details) is equivalent to:

SIGN(score_team_1 - score_team_2) = -1

The last form is handy, as the number at the end controls whether you
end up with < or >.

No idea if the different queries might have different performance -
try it and see, if it's an issue.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to