@lob_messages = ProviderMessage.find(:all,
:conditions => [ “to = ?”,
“GFA”],
:order => ‘created_at DESC’,
:limit => 5)
The Exception Rails is returning is: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 5I
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.Any assistance would
really be appreciated!TIA,Bill
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.
The Exception Rails is returning is:
And I can’t get a find with :conditions => [ “something IN (?)”,
some_array] to work either.
use some_array.joins(“,”) instead.
Any assistance would really be appreciated!
TIA,
Bill
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 [email protected]
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: