我们可以在IIF语句中使用Exists子句吗?我想根据特定条件订购输出。
Select *
From Table1 AS a
Order By IIF( Exists(Select * From Table2 Where Col_Name='Criteria'),a.Col1,a.Col2) Desc
无法在MS Access中获得结果。
答案 0 :(得分:1)
将DLookUp
或DCount
域功能视为EXISTS
子句,在MS Access表达式中不起作用:
Select *
From Table1 AS a
Order By IIF(DLookUp("Col_Name", "Table2", "Col_Name='Criteria'") IS NOT NULL, a.Col1, a.Col2) Desc
Select *
From Table1 AS a
Order By IIF(DCount("*", "Table2", "Col_Name='Criteria'") > 0, a.Col1, a.Col2) Desc