2 回答

TA貢獻1801條經驗 獲得超8個贊
Business.find_by_sql["SELECT d.name FROM businesses AS b
JOIN employees AS e ON (b.employee_id = e.id)
JOIN departments AS d ON (e.department_id = d.id)
WHERE d.code = ? AND b.out_date <= ? AND b.out_date > ?", department, upThe, downThe]

TA貢獻1864條經驗 獲得超6個贊
{:Department => 'department',:UpThe=> 'upThe',:DownThe=> 'downThe'}
你怎么這樣寫。。
api
# You can use the same string replacement techniques as you can with ActiveRecord#find
Post.find_by_sql ["SELECT title FROM posts WHERE author = ? AND created > ?", author_id, start_date]
> [#<Post:0x36bff9c @attributes={"first_name"=>"The Cheap Man Buys Twice"}>, ...]
添加回答
舉報