<cfquery name="result" datasource="Training">
select TE.firstname,TE.lastname,TD.deparmentname,TE.salary,TE.DateOfBirth
from TEmployee as TE
inner join Tdepartment as TD
on TE.departmentID=TD.departmentID
where 1 = 1
<cfif isdefined('form.fname') AND len(form.fname) gt 0 >
AND TE.FirstName Like '#Form.fname#%'
</cfif>
<cfif isdefined('form.lname') AND len(form.lname) gt 0>
and TE.LastName Like '#Form.lname#%'
</cfif>
<cfif isdefined('form.dept') AND form.dept neq 0>
and TD.DeparmentName='#form.dept#'
</cfif>
<cfif isdefined('form.salary') AND ListLen(Form.salary,'-') EQ 2>
and TE.salary between #ListGetAt(Form.salary,1,'-')# AND #ListGetAt(Form.salary,2,'-')#
</cfif>
<cfif isdefined('form.hidetxt') AND Len(form.hidetxt) GT 0>
order by #form.hidetxt#
</cfif>
</cfquery>
<cfdump var="#result#">
<cfoutput>
<cfquery dbtype="query" name="detail">
select top 2 *
FROM result
WHERE 1=1
<cfif isdefined('form.hidetxt') AND Len(form.hidetxt) GT 0>
order by #form.hidetxt#
</cfif>
</cfquery>
</cfoutput>
<cfdump var="#detail#">
前 2 位错误。但是这个查询在数据库中工作。我在这方面犯了什么错误。在“select top 2 *”中发生第二个查询错误。为此写什么