Queryappend的任何自定义函数
Queryappend 在 Coldfusion - 18 中而不是在 Coldfusion - 16 中。
任何人都可以为“Queryappend”建议任何自定义coldfusoin函数
假设我有 2 个查询:
Query-1
select * from user where userid > 10 order by userid asc
Query-2
select * from user where userid < 10 order by userid desc
Query append should return folowing:
userid username
11 AA
12 BB
13 CC
9 MM
8 NN
7 OO
提前致谢
回答
queryAppend()在早期版本的 ColdFusion 中模拟 a 的最简单和最易读的解决方案是使用查询 ( qoq)的查询,然后使用该union all功能qoq通过不提供ORDER BY子句来附加结果。
<cfquery name="query1" datasource="mydatasource">
select * from user where userid > 10 order by userid asc
</cfquery>
<cfquery name="query2" datasource="mydatasource">
select * from user where userid < 10 order by userid desc
</cfquery>
<!--- "Union all" the 2 result sets together in a qoq and don't supply an order by clause --->
<cfquery name="queryAppend" dbtype="query">
select * from query1
union all
select * from query2
</cfquery>
这是要点https://trycf.com/gist/484d3ab19f52d81867dacdced47fad09/lucee5?theme=monokai的工作示例