In my controller neighborMatches I have an array of ids:
neighborMatches = neighborMatches.map!{|n| n.id}
I want to find all the properties that match some conditions, and is also in this list of ids:
@properties = Property.find(:all, :conditions => ["(NO_BEDROOMS > ? AND NO_FULL_BATHS > ? AND SQUARE_FEET > ? AND LIST_PRICE > ? AND LIST_PRICE < ? AND id IN ?)", beds, baths, sqft, priceLow, priceHigh, neighborMatches]
I get an invalid SQL error: 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 '3,33,41,187,432,497,533,537,558,561,564,245,274,365,474,534,536,577,4,18,235,346' at line 1: SELECT * FROM properties WHERE ((NO_BEDROOMS > '1' AND NO_FULL_BATHS > '1' AND SQUARE_FEET > '500' AND LIST_PRICE > '0' AND LIST_PRICE < '99999999' AND id IN 3,33,41,187,432,497,533,537,558,561,564,245,274,365,474,534,536,577,4,18,235,346,396,439,509,66,468))
Can anyone spot the SQL syntax error? Thanks in advance!!
LAB