我编写了一个数据库查询来提取ColdFusion中的信息,我想知道如何将值传递给WHERE子句以获取相关数据。这是我的代码示例。任何人都可以帮忙吗?如何将参数值传递给ColdFusion数据库查询
<cfquery name="FILM_STRIP_QUERY" datasource="#dsn#">
select distinct tm.id as teachingmoduleid,
(select concat(prs.first_name, ' ',prs.last_name) AS Video_presenter from presentations pss
inner join topics tpcs on tpcs.id = pss.topic_id
inner join presenters prs on prs.id = pss.presenter_id
where pss.name = ps.name
and tpcs.title = tp.title
) AS video_presenter,
(select pss.43_png from presentations pss
inner join topics tpcs on tpcs.id = pss.topic_id
inner join presenters prs on prs.id = pss.presenter_id
where pss.name = ps.name
and tpcs.title = tp.title) AS png_name
from teaching_modules tm
inner join tm_segments sg on sg.module_id = tm.id
inner join topics tp on tp.id = sg.topic_id
inner join presenters prs on prs.id = tm.presenter_id
left outer join presentations ps on ps.id = sg.presentation_id
where tm.id =
</cfquery>
,这是调用函数
<cfloop = "FILM_STRIP_QUERY">
<!--- this is where I wanna pass the parameter--->
</cfloop>
不要忘记VAR范围FILM_STRIP_QUERY。此外,此代码不会按原样运行,应该是 –
duncan
2012-02-06 15:21:25
好点,更新后 – jamesTheProgrammer 2012-02-06 15:25:29