我收到一个错误;列名“阶段”无效。我已经尝试了所有我能想到的排列方式。
<cfargument name="locationFilter" default="" />
<cfargument name="educationFilter" default="" />
<cfargument name="workFilter" default="" />
<cfargument name="diversityFilter" default="" />
<cfargument name="phaseFilter" default="" />
<cfquery name="QMentors" datasource="#request.dsn_live#">
SELECT
(case
when datepart(year,getdate())-cast(yearstarted as integer) > 29 then '5'
when datepart(year,getdate())-cast(yearstarted as integer) > 13 then '4'
when datepart(year,getdate())-cast(yearstarted as integer) > 5 then '3'
when datepart(year,getdate())-cast(yearstarted as integer) > 1 then '2'
else '1'
end) as phase, *
FROM mentors
WHERE 0=0
AND mentortype='mentor'
AND approved='true'
AND active='true'
AND mentorcat LIKE '%general%'
<cfif arguments.locationFilter neq ""> AND location LIKE <cfqueryparam value="%#arguments.locationFilter#%" /></cfif>
<cfif arguments.educationFilter neq ""> AND educationhistory LIKE <cfqueryparam value="%#arguments.educationFilter#%" /></cfif>
<cfif arguments.workFilter neq ""> AND workhistory LIKE <cfqueryparam value="%#arguments.workFilter#%" /></cfif>
<cfif arguments.diversityFilter eq "Diversity"> AND mentorcat LIKE <cfqueryparam value="%#arguments.diversityFilter#%" /></cfif>
<cfif arguments.phaseFilter neq ""> AND phase = <cfqueryparam value="#arguments.phaseFilter#" /></cfif>
ORDER BY lastname
</cfquery>
我想我最好显示整个查询。