Hi,
I have a complex SQL request to perform. I don't want to manually do the whole query (find_by_sql) because of the complex joins, but I want to use MySQL functions, such as:
Model.find(:all, :include => [../..], :conditions => ["(../..) AND YEAR(STR_TO_DATE(my_table.my_row,'%Y-%m-%d %H:%i:%s')) = #{year})"], :select => [../..])
or
Model.find(:all, :include => [../..], :conditions => ["(../..) AND YEAR(STR_TO_DATE(my_table.my_row,GET_FORMAT(DATETIME,'ISO'))) = #{year})"], :select => [../..])
Is there a way to combine the power of AR and SQL functions?
In the example above, I could use Ruby Time Class but what can I do if I want to use more specific SQL syntax (UNION, ...). I guess I have to make the joins by hand with find_by_sql?