In my Rails 4 app I need to find all plans that do either have an interval of month OR an amount of 0.
This doesn't work:
class Plan < ActiveRecord::Base def self.by_interval(interval) where("interval = ? OR amount = ?", interval, 0) end end I am getting this error:
Mysql2::Error: 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 '= 'month' OR amount = 0) ORDER BY amount DESC' at line 1: SELECT `plans`.* FROM `plans` WHERE (interval = 'month' OR amount = 0) ORDER BY amount DESC What else might work?
Thanks for any help.
Mysql2::Error: 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 'LIKE ''month'' OR amount = 0)' at line 1: SELECT plans.* FROM plans WHERE (interval LIKE ''month'' OR amount = 0)interval? Is it a kind of string/text/varchar?