Mysql::Error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to = 'GFA') ORDER BY created_at DESC LIMIT 5' at line 1: SELECT * FROM provider_messages WHERE (to = 'GFA') ORDER BY created_at DESC LIMIT 5
I really would appreciate another set of eyeballs. Anybody see anything wrong with the find?
And I can't get a find with :conditions => [ "something IN (?)", some_array] to work either.
Mysql::Error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'to = 'GFA') ORDER BY created_at DESC LIMIT 5' at line 1: SELECT * FROM provider_messages WHERE (to = 'GFA') ORDER BY created_at DESC LIMIT 5
I really would appreciate another set of eyeballs. Anybody see anything wrong with the find?
It seems “to” is a reserved word in mysql, check the manual yourself.
And I can't get a find with :conditions => [ "something IN (?)", some_array] to work either.
While I’d strongly suggest that you change the name of that column, if you actually managed to create a column with that name, you should be able to add ID quotes (that is, backticks or grave accents) to the column name:
Rob,
Would you mind taking this one step further and show how I'd write the
condition to find an integer instead of a string.
I get the same error message described above when I try to make
the :condition for an integer like this;
:conditions => [ 'intfieldvalue = ?, intvalue']
surprisingly, it passes with this, but the condition is disregared for
some reason?
:conditions => [ 'intfieldvalue = intvalue']
I am grateful for a reply.
Kathy
KathysKode@gmail.com
Rob,
Would you mind taking this one step further and show how I'd write the
condition to find an integer instead of a string.
I get the same error message described above when I try to make
the :condition for an integer like this;
:conditions => [ 'intfieldvalue = ?, intvalue']
That has to be:
:conditions => ['intfieldvalue = ?', intvalue]
The values to be interpolated have to be outside the string, as
separate array elements.
surprisingly, it passes with this, but the condition is disregared for
some reason?
:conditions => [ 'intfieldvalue = intvalue']
If you want it all in one string (usually not advisable, for security
reasons), you'd have to do Ruby-style string interpolation: