Find_by_sql

hi,

i have to fire below query…
SELECT * FROM clarify_crs c where c.id IN (select cscr.cscr_cr_id from
clarify_case_crs cscr where cscr.cscr_case_id=10001);

I have to pass this 10001 as some variable. So i am using below query,

cs_id=params[:id]
@lnkcr = Cl.find_by_sql(‘SELECT * FROM crs c WHERE c.id IN (SELECT
cscr.cscr_cr_id FROM case_crs cscr WHERE cscr.cscr_case_id=?)’,cs_id)

but i am getting error message saying that “wrong number of arguments (2
for 1)”.

Please help. it is very important to me…

find_by_sql doesn’t work as the :conditions in normal finds.
just use:

@lnkcr = Cl.find_by_sql(“SELECT * FROM crs c WHERE c.id IN (SELECT
cscr.cscr_cr_id FROM case_crs cscr WHERE cscr.cscr_case_id=#{cs_id})”)

It works…
Thank you very much Thorsten…

Thorsten M. wrote:

find_by_sql doesn’t work as the :conditions in normal finds.
just use:

@lnkcr = Cl.find_by_sql(“SELECT * FROM crs c WHERE c.id IN (SELECT
cscr.cscr_cr_id FROM case_crs cscr WHERE cscr.cscr_case_id=#{cs_id})”)