Thursday 15 April 2010

sql - Math operations inside where claue of rails -


The table (days_of_weeks) consists of 8 columns, an ID, and the rest of the day on the day (Sun, Mars, tue ...) Where in the days of week either 0 or 1

I need to find the rows whose numbers are less than 3 in the week.

Write as an SQL Statement

 Choose an ID from day_of_week where (Mond + Tu + Weed + Thu + Fry + SAT + Sun) & lt; 3;   

I'm trying to query it by rail

  dayoffupic Selection (ID). Where ((:: Sun + +: tue +: wed +: Thu +: fri +: sat +: sun) <3)   

This error shows because its just a symbol , I have tried .to_i, but no luck

I know that I can directly ask a SQL statement from the rail, but I want to rail it?

As the string position in the .where class ActiveRecord, will the following be considered "an SQL statement"?

  dayoffware. Selection (: ID). Where ('(+ mon + tu + weed + thu + fly + sat + sun)' <3))    

No comments:

Post a Comment