我想在此查询中添加UNION,在下面的灵活搜索查询中,我应该将UNION放在哪里(与UNION的代码无关,我只想知道可以放在哪里)不熟悉语法)
我尝试将其放在最后一行中,但无法编译。
有什么提示吗?
对于UNION查询或INNER查询,您将需要在双花括号之间包装各自的查询。
{{..query1..}} UNION {{..query2..}}
查看以下示例以获取灵活的查询联合示例。
SELECT uniontable.PK, uniontable.CODE FROM ( {{ SELECT {c:PK} as PK, {c:code} AS CODE FROM {Chapter AS c} WHERE {c:PUBLICATION} LIKE ?pk }} UNION ALL {{ SELECT {p:PK} as PK, {p:code} AS CODE FROM {Page AS p} WHERE {p:PUBLICATION} LIKE ?pk }} ) uniontable
您可以在https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1905/zh-CN/8bc36ba986691014b48be171221d1f4f.html上找到FlexibleSearch提示和技巧。
希望能帮助到你!
修复了查询的前半部分...
SELECT tbl.startTime FROM ( {{ SELECT MAX({h.startTime}) AS startTime FROM {CronJobHistory AS h JOIN CronJobResult AS r ON {h.result} = {r.pk} } WHERE {h.cronJobCode} = 'ordersCronJob' AND {r.code} = 'SUCCESS' }} UNION {{ SELECT MAX({h.startTime}) AS startTime FROM {CronJobHistory as h} WHERE {h.cronJobCode} = 'ordersCronJob' }} ) tbl