mardi 7 mars 2017

Why is it a syntax error? [duplicate]

This question already has an answer here:

Simple query like this.

MyModel.where('student_id = :id AND from <= :date AND to >= :date', {:id => student.id, :date => day.to_s(:db)})

Returns an exception

=> ActiveRecord::JDBCError: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'from <= '2017-02-28 00:00:00.000' AND to >= '2017-02-28 00:00:00.000')'

And I don't get why.

Aucun commentaire:

Enregistrer un commentaire