# find\_by\_sql with named parameterized sql

**URL:** <https://discuss.rubyonrails.org/t/find-by-sql-with-named-parameterized-sql/7505>\
**Category:** rubyonrails-talk\
**Created:** [January 20, 2007, 7:01pm UTC](https://discuss.rubyonrails.org/t/find-by-sql-with-named-parameterized-sql/7505 "2007-01-20T19:01:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![August\_Lilleaas](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@August\_Lilleaas](https://discuss.rubyonrails.org/u/August_Lilleaas)\
**Post date:** [January 20, 2007, 7:01pm UTC](https://discuss.rubyonrails.org/t/find-by-sql-with-named-parameterized-sql/7505/1 "2007-01-20T19:01:37Z")

</div>

The latter isn't working because you are inserting symbols directly in the sql, and as far as I know this isn't allowed. What's wrong with using the first alternative?

---

<div class="post-metadata">

**Author:** ![August\_Lilleaas](https://avatars.discourse-cdn.com/v4/letter/a/7bcc69/32.png) [@August\_Lilleaas](https://discuss.rubyonrails.org/u/August_Lilleaas)\
**Post date:** [January 20, 2007, 7:05pm UTC](https://discuss.rubyonrails.org/t/find-by-sql-with-named-parameterized-sql/7505/2 "2007-01-20T19:05:27Z")

</div>

By the way, I reccomend doing this instead:

@order = Order.find(:all, :conditions =\> ["amount \> ? and quantity \> ?", @amount, @quantity]

Just in case you feel like making the orders table a legacy table called "15\_t\_orders" or whatever, you're keeping your app DRY by using the rails finders instead of sql, and only having the data finding itself in the sql part.
