# MySQL Where conditions automatic formatting

**URL:** <https://www.ruby-forum.com/t/mysql-where-conditions-automatic-formatting/107849>\
**Category:** Rails\
**Created:** [June 26, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/mysql-where-conditions-automatic-formatting/107849 "2007-06-26T20:50:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@jwm](https://www.ruby-forum.com/u/jwm)\
**Post date:** [June 26, 2007, 8:50pm UTC](https://www.ruby-forum.com/t/mysql-where-conditions-automatic-formatting/107849/1 "2007-06-26T20:50:16Z")

</div>

Hi,

I’m having a problem with the automatic formatting of my mysql query.

My code is this:

Tablename.find(:all, :conditions =\> {:id =\> list})

Where list is a list of id’s (8,9,10)

The problem is that the query is automatically formatted to this:

SELECT \* FROM Tablename WHERE (id in (‘8,7,9’))

I need this query to run without the extra single quotes to work  
properly.

ie: SELECT \* FROM identifications WHERE (id in (8,7,9))

How do I go about this?

Thanks,

Jonathon

---

<div class="post-metadata">

**Author:** ![jwm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@jwm](https://www.ruby-forum.com/u/jwm)\
**Post date:** [June 26, 2007, 9:13pm UTC](https://www.ruby-forum.com/t/mysql-where-conditions-automatic-formatting/107849/2 "2007-06-26T21:13:24Z")

</div>

Thanks

---

<div class="post-metadata">

**Author:** ![jwm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c37758/32.png) [@jwm](https://www.ruby-forum.com/u/jwm)\
**Post date:** [June 26, 2007, 9:02pm UTC](https://www.ruby-forum.com/t/mysql-where-conditions-automatic-formatting/107849/3 "2007-06-26T21:02:16Z")

</div>

On 6/26/07, Jonathon Paul M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The problem is that the query is automatically formatted to this:
> 
> SELECT \* FROM Tablename WHERE (id in (‘8,7,9’))
> 
> I need this query to run without the extra single quotes to work properly.
> 
> ie: SELECT \* FROM identifications WHERE (id in (8,7,9))
> 
> How do I go about this?

list needs to be an Array, not a String:

list = [8,7,9] # array of values

It looks like you have list as a string “8,7,9”, which is a single  
value.
