find_by_sql Method

Hello guys!

I am new in rails.

I am querying the courses table for specific courses that belong to
specific institute using this sql statement. I'm getting the same
courses for all the institutes that I have. Any help on what to put in
place of 1 or how to restructure my query will be highly appreciated.

Here is my query!

<%= select ("course_code", "course_name",Course.find_by_sql("select, c.course_name from institutes as i, courses as c ,
institute_courses as ic where = ic.institute_id and =
ic.course_id and = 1;").collect {|c| [ c.course_name, ] })%>