# Ruby and mysql syntax? tried single quotes, double, none,

**URL:** <https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232>\
**Category:** Rails\
**Created:** [August 13, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232 "2006-08-13T18:53:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [August 13, 2006, 6:53pm UTC](https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232/1 "2006-08-13T18:53:21Z")

</div>

Hi, how do i use passed in arguments and convert those to something sql  
can understand? do the aliases have to be double qouted? single qouted?  
i think i tried all but no avail…thanks!

def get\_count(doctype, towne)

@profiles = Profile.count\_by\_sql(“SELECT COUNT(\*) from Profiles where  
Profiles.doctype\_id = 1 and town\_id = towne”)

end

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [August 13, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232/2 "2006-08-13T19:12:50Z")

</div>

koloa wrote:

> Hi, how do i use passed in arguments and convert those to something sql  
> can understand? do the aliases have to be double qouted? single qouted?  
> i think i tried all but no avail…thanks!
> 
> def get\_count(doctype, towne)
> 
> @profiles = Profile.count\_by\_sql(“SELECT COUNT(\*) from Profiles where  
> Profiles.doctype\_id = 1 and town\_id = towne”)
> 
> end

Try

Profile.count\_by\_sql([“SELECT COUNT(\*) from Profiles where  
Profiles.doctype\_id = ? and town\_id = ?”, doctype, towne])

or look for examples at

[http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870](http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870)

Stephan

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [August 13, 2006, 8:19pm UTC](https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232/3 "2006-08-13T20:19:17Z")

</div>

Hello Stephan, Thanks!

---

<div class="post-metadata">

**Author:** ![koloa](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/4bbf92/32.png) [@koloa](https://www.ruby-forum.com/u/koloa)\
**Post date:** [April 10, 2009, 12:43pm UTC](https://www.ruby-forum.com/t/ruby-and-mysql-syntax-tried-single-quotes-double-none/102232/4 "2009-04-10T12:43:10Z")

</div>

> or look for examples at
> 
> [http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870](http://rubyonrails.org/api/classes/ActiveRecord/Base.html#M000870)
> 
> Stephan

Hi Stephan,  
i have the same issue as discuss here. i try above given link but  
it is not working. could you give me the other link or some direction to  
avoid the Double Quotes problem.

Thanks  
Salil
